From 9c9d846fbf2f038d5a775281dcd4902b13dca919 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Thu, 13 Jun 2024 12:17:57 +1000 Subject: [PATCH 01/24] Reduce double precision in LFE PLC to single --- lib_com/ivas_prot.h | 2 +- lib_com/ivas_rom_com.c | 2 +- lib_com/ivas_rom_com.h | 2 +- lib_dec/ivas_lfe_plc.c | 233 +++++++++-------------------------------- 4 files changed, 55 insertions(+), 184 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 779b328d97..1ce5153e7b 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5495,7 +5495,7 @@ void ivas_lfe_dec( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ - const float *prevsynth, /* i : previous frame synthesis */ + float *prevsynth, /* i : previous frame synthesis */ float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ ); diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index ffd5d578de..51e5643774 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3124,7 +3124,7 @@ const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; const float ivas_lfe_lpf_delay[2] = { 0.00175f, 0.0035f }; -const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = +const float d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = { 0.08000000000000002, 0.08015895227847719, 0.08063569926248770, 0.08142991147368656, 0.08254104003450596, 0.08396831704748331, 0.08571075612595230, 0.08776715307573196, 0.09013608672734141, 0.09281591991816535, 0.09580480062389246, 0.09910066323844335, 0.10270123000150438, 0.10660401257268071, 0.11080631375118072, 0.11530522933984272, diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index 5983062648..fc2d3133d8 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -359,7 +359,7 @@ extern const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP]; extern const ivas_lfe_freq_models ivas_str_lfe_freq_models; extern const float ivas_lfe_lpf_delay[2]; -extern const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2]; +extern const float d_hamm_lfe_plc[LFE_PLC_LENANA / 2]; extern const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1]; extern const float ivas_cos_twiddle_480[IVAS_480_PT_LEN >> 1]; diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index d74cbc7772..7b57e5e70d 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -52,114 +52,20 @@ #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) -#define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ +#define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ #define MAX_LEN_LP 960 -#define EPS_STOP 1e-5 +#define EPS_STOP 1e-5f /*------------------------------------------------------------------------------------------* * Static function declarations * - * Note (DLB): the local double precision functions defined below are replica of corresponding + * Note (DLB): the local float precision functions defined below are replica of corresponding * float functions defined in tools.c, lpc_tools.c and syn_filt.c. - * Double precision arithmetic is required for proper functioning of the lfe_plc. + * float precision arithmetic is required for proper functioning of the lfe_plc. *------------------------------------------------------------------------------------------*/ -static void mvr2d( - const float x[], /* i : input vector */ - double y[], /* o : output vector */ - const int16_t n /* i : vector size */ -) -{ - int16_t i; - - if ( n <= 0 ) - { - /* cannot transfer vectors with size 0 */ - return; - } - - for ( i = n - 1; i >= 0; i-- ) - { - y[i] = x[i]; - } - - return; -} - - -/*---------------------------------------------------------------------* - * autocorr() - * - * Compute autocorrelations of input signal - *---------------------------------------------------------------------*/ - -static void d_autocorr( - const double *x, /* i : input signal */ - double *r, /* o : autocorrelations vector */ - const int16_t m, /* i : order of LP filter */ - const int16_t len, /* i : window size */ - const double *wind, /* i : window */ - const int16_t rev_flag, /* i : flag to reverse window */ - const int16_t sym_flag, /* i : symmetric window flag */ - const int16_t no_thr /* i : flag to avoid thresholding */ -) -{ - double t[MAX_LEN_LP]; - double s; - int16_t i, j; - - /* Windowing of signal */ - if ( rev_flag == 1 ) - { - /* time reversed window */ - for ( i = 0; i < len; i++ ) - { - t[i] = x[i] * wind[len - i - 1]; - } - } - else if ( sym_flag == 1 ) - { - /* symmetric window of even length */ - for ( i = 0; i < len / 2; i++ ) - { - t[i] = x[i] * wind[i]; - } - - for ( ; i < len; i++ ) - { - t[i] = x[i] * wind[len - 1 - i]; - } - } - else /* assymetric window */ - { - for ( i = 0; i < len; i++ ) - { - t[i] = x[i] * wind[i]; - } - } - - /* Compute r[1] to r[m] */ - for ( i = 0; i <= m; i++ ) - { - s = t[0] * t[i]; - for ( j = 1; j < len - i; j++ ) - { - s += t[j] * t[i + j]; - } - r[i] = s; - } - - if ( r[0] < 100.0f && no_thr == 0 ) - { - r[0] = 100.0f; - } - - return; -} - - /*---------------------------------------------------------------------* * lev_dur() * @@ -169,21 +75,22 @@ static void d_autocorr( /*! r: energy of prediction error */ static int16_t d_lev_dur( - double *a, /* o : LP coefficients (a[0] = 1.0) */ - const double *r, /* i : vector of autocorrelations */ + float *a_out, /* o : LP coefficients (a[0] = 1.0) */ + const float *r, /* i : vector of autocorrelations */ const int16_t m, /* i : order of LP filter */ - double epsP[] /* o : prediction error energy */ + float epsP[] /* o : prediction error energy */ ) { int16_t i, j, l; - double buf[TCXLTP_LTP_ORDER]; - double *rc; /* reflection coefficients 0,...,m-1 */ - double s, at, err; + float buf[TCXLTP_LTP_ORDER]; + float *rc; /* reflection coefficients 0,...,m-1 */ + float s, at, err; int16_t flag = 0; + float a[LFE_PLC_LPCORD + 1] = {0.f}; rc = &buf[0]; rc[0] = ( -r[1] ) / r[0]; - a[0] = 1.0; + a[0] = 1.0f; a[1] = rc[0]; err = r[0] + r[1] * rc[0]; @@ -195,7 +102,7 @@ static int16_t d_lev_dur( for ( i = 2; i <= m; i++ ) { - s = 0.0; + s = 0.0f; for ( j = 0; j < i; j++ ) { s += r[i - j] * a[j]; @@ -205,6 +112,14 @@ static int16_t d_lev_dur( if ( fabs( rc[i - 1] ) > 0.99945f ) { flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ + return flag; + } + else + { + for (j = 0; j < i; j++) + { + a_out[j] = a[j]; + } } for ( j = 1; j <= i / 2; j++ ) { @@ -239,14 +154,14 @@ static int16_t d_lev_dur( *-------------------------------------------------------------------*/ static uint16_t d_a2rc( - const double *a, /* i : LPC coefficients */ - double *refl, /* o : Reflection co-efficients */ + const float *a, /* i : LPC coefficients */ + float *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ ) { - double ff[LFE_PLC_LPCORD]; + float ff[LFE_PLC_LPCORD]; int16_t m, j, n; - double km, denom, x; + float km, denom, x; for ( m = 0; m < lpcorder; m++ ) { @@ -257,18 +172,18 @@ static uint16_t d_a2rc( for ( m = lpcorder - 1; m >= 0; m-- ) { km = ff[m]; - if ( km <= -1.0 || km >= 1.0 ) + if ( km <= -1.0f || km >= 1.0f ) { for ( j = 0; j < lpcorder; j++ ) { - refl[j] = 0.0; + refl[j] = 0.0f; } return 0; } refl[m] = -km; - denom = 1.0 / ( 1.0 - km * km ); + denom = 1.0f / ( 1.0f - km * km ); for ( j = 0; j < m / 2; j++ ) { n = m - 1 - j; @@ -286,50 +201,6 @@ static uint16_t d_a2rc( return 1; } - -static void d_syn_filt( - const double 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 */ - const float mem[] /* i : initial filter states */ -) -{ - int16_t i, j; - double buf[LFE_PLC_LPCORD + LFE_PLC_RECLEN]; /* temporary synthesis buffer */ - double s, *yy; - - yy = &buf[0]; - - /*------------------------------------------------------------------* - * copy initial filter states into synthesis buffer and do synthesis - *------------------------------------------------------------------*/ - for ( i = 0; i < m; i++ ) - { - *yy++ = mem[i]; - } - - /*-----------------------------------------------------------------------* - * Do the filtering - *-----------------------------------------------------------------------*/ - - for ( i = 0; i < l; i++ ) - { - s = x[i]; - for ( j = 1; j <= m; j++ ) - { - s -= a[j] * yy[i - j]; - } - - yy[i] = s; - y[i] = (float) s; - } - - return; -} - - /*-----------------------------------------------------------------------------------------* * Function check_stab() * @@ -337,16 +208,16 @@ static void d_syn_filt( *-----------------------------------------------------------------------------------------*/ static uint16_t check_stab( - const double *a, - double delta ) + const float *a, + float delta ) { - double amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; + float amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; int16_t i; - double fac; - double fac1; + float fac; + float fac1; uint16_t stable; - fac = 1.0 + delta; + fac = 1.0f + delta; fac1 = fac; for ( i = 0; i < LFE_PLC_LPCORD; i++ ) @@ -366,16 +237,16 @@ static uint16_t check_stab( * Find maximum LPC filter sharpening by iteration to get a filter that is almost instable *-----------------------------------------------------------------------------------------*/ -static double find_max_delta( - double *a ) +static float find_max_delta( + float *a ) { - double delta; - double eps; + float delta; + float eps; uint16_t stable; - double fac; + float fac; - delta = 0.0; - eps = 0.01; + delta = 0.0f; + eps = 0.01f; fac = 2; stable = FALSE; @@ -385,7 +256,7 @@ static double find_max_delta( eps *= fac; stable = TRUE; } - fac = 0.5; + fac = 0.5f; if ( stable ) { @@ -440,16 +311,16 @@ static double find_max_delta( static void recover_samples( const int16_t bfi_count, - const float *outbuf, + float *outbuf, float *rec_frame ) { int16_t i; float zeroes[LFE_PLC_RECLEN]; - double delta, fac, att; - double d_outbuf[LFE_PLC_BUFLEN], d_r[LFE_PLC_LPCORD + 1], d_a[LFE_PLC_LPCORD + 1], d_pee[LFE_PLC_LPCORD + 1]; + float delta, fac, att; + float d_outbuf[LFE_PLC_BUFLEN], d_r[LFE_PLC_LPCORD + 1], d_a[LFE_PLC_LPCORD + 1] = {0.f}, d_pee[LFE_PLC_LPCORD + 1] = {0.f}; - mvr2d( outbuf, d_outbuf, LFE_PLC_BUFLEN ); - d_autocorr( d_outbuf, d_r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc, 0, 1, 1 ); + mvr2r( outbuf, d_outbuf, LFE_PLC_BUFLEN ); + autocorr( d_outbuf, d_r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc, 0, 1, 1 ); if ( d_r[0] < POW_THR * LFE_PLC_BUFLEN ) { @@ -460,8 +331,8 @@ static void recover_samples( delta = find_max_delta( d_a + 1 ); - fac = 1.0 + delta; - att = 1.0; + fac = 1.0f + delta; + att = 1.0f; if ( bfi_count >= LFE_PLC_MUTE_THR ) { @@ -472,11 +343,11 @@ static void recover_samples( for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) { d_a[i] = d_a[i] * fac; - fac *= att * ( 1.0 + delta ); + fac *= att * ( 1.0f + delta ); } set_zero( zeroes, LFE_PLC_RECLEN ); - d_syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD ); + syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); return; } @@ -490,7 +361,7 @@ static void recover_samples( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ - const float *prevsynth, /* i : previous frame synthesis */ + float *prevsynth, /* i : previous frame synthesis */ float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ ) -- GitLab From f5085133527e88c4f7cf784638bcdde6fa61578d Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Thu, 20 Jun 2024 12:00:22 +1000 Subject: [PATCH 02/24] code review cleanup --- lib_com/ivas_rom_com.c | 34 +++++++++++++++++----------------- lib_com/ivas_rom_com.h | 2 +- lib_dec/ivas_lfe_plc.c | 23 +++++++++++------------ 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 51e5643774..7ca8d97ab9 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3124,23 +3124,23 @@ const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; const float ivas_lfe_lpf_delay[2] = { 0.00175f, 0.0035f }; -const float d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = -{ - 0.08000000000000002, 0.08015895227847719, 0.08063569926248770, 0.08142991147368656, 0.08254104003450596, 0.08396831704748331, 0.08571075612595230, 0.08776715307573196, - 0.09013608672734141, 0.09281591991816535, 0.09580480062389246, 0.09910066323844335, 0.10270123000150438, 0.10660401257268071, 0.11080631375118072, 0.11530522933984272, - 0.12009765015221685, 0.12518026416131367, 0.13054955878853602, 0.13620182333121073, 0.14213315152704381, 0.14833944425372619, 0.15481641236182375, 0.16155957963899570, - 0.16856428590349043, 0.17582569022478273, 0.18333877426912554, 0.19109834576770490, 0.19909904210500018, 0.20733533402487142, 0.21580152945181053, 0.22449177742471671, - 0.23340007214047787, 0.24252025710456171, 0.25184602938575001, 0.26137094397207467, 0.27108841822494550, 0.28099173642839037, 0.29107405443026624, 0.30132840437223085, - 0.31174769950520753, 0.32232473908701620, 0.33305221335878232, 0.34392270859668939, 0.35492871223557998, 0.36606261806086549, 0.37731673146515798, 0.38868327476598852, - 0.40015439258093899, 0.41172215725647360, 0.42337857434671339, 0.43511558813837425, 0.44692508721804453, 0.45879891007795709, 0.47072885075638249, 0.48270666450874267, - 0.49472407350552849, 0.50677277255308162, 0.51884443483328757, 0.53093071765821398, 0.54302326823571601, 0.55511372944202464, 0.56719374559732838, 0.57925496824035816, - 0.59128906189798180, 0.60328770984582458, 0.61524261985593010, 0.62714552992749328, 0.63898821399670414, 0.65076248762175315, 0.66246021363907504, 0.67407330778691554, - 0.68559374429233988, 0.69701356141781945, 0.70832486696356345, 0.71951984372179334, 0.73059075487919101, 0.74152994936378558, 0.75232986713258543, 0.76298304439630038, - 0.77348211877754336, 0.78381983439894576, 0.79398904689767136, 0.80398272836286389, 0.81379397219261318, 0.82341599786708708, 0.83284215563452701, 0.84206593110687011, - 0.85108094976182280, 0.85988098134827329, 0.86845994419199846, 0.87681190939868969, 0.88493110495139349, 0.89281191969953333, 0.90044890723675941, 0.90783678966494241, - 0.91497046124171255, 0.92184499190902180, 0.92845563070029180, 0.93479780902379184, 0.94086714381997805, 0.94665944059061280, 0.95217069629756890, 0.95739710212931617, - 0.96233504613317988, 0.96698111571154954, 0.97133209998031445, 0.97538499198789563, 0.97913699079334116, 0.98258550340204664, 0.98572814655776630, 0.98856274838967395, - 0.99108734991333569, 0.99330020638455863, 0.99519978850517732, 0.99678478347994692, 0.99805409592381300, 0.99900684861892730, 0.99964238312089115, 0.99996026021380402 +const float hamm_lfe_plc[LFE_PLC_LENANA / 2] = +{ + 0.08000000000000002f, 0.08015895227847719f, 0.08063569926248770f, 0.08142991147368656f, 0.08254104003450596f, 0.08396831704748331f, 0.08571075612595230f, 0.08776715307573196f, + 0.09013608672734141f, 0.09281591991816535f, 0.09580480062389246f, 0.09910066323844335f, 0.10270123000150438f, 0.10660401257268071f, 0.11080631375118072f, 0.11530522933984272f, + 0.12009765015221685f, 0.12518026416131367f, 0.13054955878853602f, 0.13620182333121073f, 0.14213315152704381f, 0.14833944425372619f, 0.15481641236182375f, 0.16155957963899570f, + 0.16856428590349043f, 0.17582569022478273f, 0.18333877426912554f, 0.19109834576770490f, 0.19909904210500018f, 0.20733533402487142f, 0.21580152945181053f, 0.22449177742471671f, + 0.23340007214047787f, 0.24252025710456171f, 0.25184602938575001f, 0.26137094397207467f, 0.27108841822494550f, 0.28099173642839037f, 0.29107405443026624f, 0.30132840437223085f, + 0.31174769950520753f, 0.32232473908701620f, 0.33305221335878232f, 0.34392270859668939f, 0.35492871223557998f, 0.36606261806086549f, 0.37731673146515798f, 0.38868327476598852f, + 0.40015439258093899f, 0.41172215725647360f, 0.42337857434671339f, 0.43511558813837425f, 0.44692508721804453f, 0.45879891007795709f, 0.47072885075638249f, 0.48270666450874267f, + 0.49472407350552849f, 0.50677277255308162f, 0.51884443483328757f, 0.53093071765821398f, 0.54302326823571601f, 0.55511372944202464f, 0.56719374559732838f, 0.57925496824035816f, + 0.59128906189798180f, 0.60328770984582458f, 0.61524261985593010f, 0.62714552992749328f, 0.63898821399670414f, 0.65076248762175315f, 0.66246021363907504f, 0.67407330778691554f, + 0.68559374429233988f, 0.69701356141781945f, 0.70832486696356345f, 0.71951984372179334f, 0.73059075487919101f, 0.74152994936378558f, 0.75232986713258543f, 0.76298304439630038f, + 0.77348211877754336f, 0.78381983439894576f, 0.79398904689767136f, 0.80398272836286389f, 0.81379397219261318f, 0.82341599786708708f, 0.83284215563452701f, 0.84206593110687011f, + 0.85108094976182280f, 0.85988098134827329f, 0.86845994419199846f, 0.87681190939868969f, 0.88493110495139349f, 0.89281191969953333f, 0.90044890723675941f, 0.90783678966494241f, + 0.91497046124171255f, 0.92184499190902180f, 0.92845563070029180f, 0.93479780902379184f, 0.94086714381997805f, 0.94665944059061280f, 0.95217069629756890f, 0.95739710212931617f, + 0.96233504613317988f, 0.96698111571154954f, 0.97133209998031445f, 0.97538499198789563f, 0.97913699079334116f, 0.98258550340204664f, 0.98572814655776630f, 0.98856274838967395f, + 0.99108734991333569f, 0.99330020638455863f, 0.99519978850517732f, 0.99678478347994692f, 0.99805409592381300f, 0.99900684861892730f, 0.99964238312089115f, 0.99996026021380402f }; diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index fc2d3133d8..9b03ebc4b6 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -359,7 +359,7 @@ extern const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP]; extern const ivas_lfe_freq_models ivas_str_lfe_freq_models; extern const float ivas_lfe_lpf_delay[2]; -extern const float d_hamm_lfe_plc[LFE_PLC_LENANA / 2]; +extern const float hamm_lfe_plc[LFE_PLC_LENANA / 2]; extern const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1]; extern const float ivas_cos_twiddle_480[IVAS_480_PT_LEN >> 1]; diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 7b57e5e70d..7d271534f4 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -74,7 +74,7 @@ *---------------------------------------------------------------------*/ /*! r: energy of prediction error */ -static int16_t d_lev_dur( +static int16_t lfeplc_lev_dur( float *a_out, /* o : LP coefficients (a[0] = 1.0) */ const float *r, /* i : vector of autocorrelations */ const int16_t m, /* i : order of LP filter */ @@ -116,7 +116,7 @@ static int16_t d_lev_dur( } else { - for (j = 0; j < i; j++) + for (j = 0; j <= m; j++) { a_out[j] = a[j]; } @@ -153,7 +153,7 @@ static int16_t d_lev_dur( * Convert from LPC to reflection coeff *-------------------------------------------------------------------*/ -static uint16_t d_a2rc( +static uint16_t lfeplc_a2rc( const float *a, /* i : LPC coefficients */ float *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ @@ -225,7 +225,7 @@ static uint16_t check_stab( amod[i] = a[i] * fac; fac *= fac1; } - stable = d_a2rc( amod, refl, LFE_PLC_LPCORD ); + stable = lfeplc_a2rc( amod, refl, LFE_PLC_LPCORD ); return stable; } @@ -317,19 +317,18 @@ static void recover_samples( int16_t i; float zeroes[LFE_PLC_RECLEN]; float delta, fac, att; - float d_outbuf[LFE_PLC_BUFLEN], d_r[LFE_PLC_LPCORD + 1], d_a[LFE_PLC_LPCORD + 1] = {0.f}, d_pee[LFE_PLC_LPCORD + 1] = {0.f}; + float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1], pee[LFE_PLC_LPCORD + 1]; - mvr2r( outbuf, d_outbuf, LFE_PLC_BUFLEN ); - autocorr( d_outbuf, d_r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc, 0, 1, 1 ); + autocorr(outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); - if ( d_r[0] < POW_THR * LFE_PLC_BUFLEN ) + if ( r[0] < POW_THR * LFE_PLC_BUFLEN ) { set_zero( rec_frame, LFE_PLC_RECLEN ); return; } - d_lev_dur( d_a, d_r, LFE_PLC_LPCORD, d_pee ); + lfeplc_lev_dur( a, r, LFE_PLC_LPCORD, pee ); - delta = find_max_delta( d_a + 1 ); + delta = find_max_delta( a + 1 ); fac = 1.0f + delta; att = 1.0f; @@ -342,12 +341,12 @@ static void recover_samples( for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) { - d_a[i] = d_a[i] * fac; + a[i] = a[i] * fac; fac *= att * ( 1.0f + delta ); } set_zero( zeroes, LFE_PLC_RECLEN ); - syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); + syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); return; } -- GitLab From cc42669c68afae8e84d10bcf22aa4bce77901277 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Thu, 27 Jun 2024 11:59:45 +1000 Subject: [PATCH 03/24] fix infinite loop --- lib_dec/ivas_lfe_plc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 7d271534f4..e4bbe578d7 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -40,6 +40,7 @@ #include "debug.h" #endif #include "wmc_auto.h" +#include "string.h" /*------------------------------------------------------------------------------------------* * Local constants @@ -94,6 +95,8 @@ static int16_t lfeplc_lev_dur( a[1] = rc[0]; err = r[0] + r[1] * rc[0]; + memcpy(a_out, a, sizeof(a)); + if ( epsP != NULL ) { epsP[0] = r[0]; @@ -318,7 +321,6 @@ static void recover_samples( float zeroes[LFE_PLC_RECLEN]; float delta, fac, att; float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1], pee[LFE_PLC_LPCORD + 1]; - autocorr(outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); if ( r[0] < POW_THR * LFE_PLC_BUFLEN ) -- GitLab From d1ea23bf80aa71f9d77cac01b0497027cba5f203 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Mon, 15 Jul 2024 17:26:25 +1000 Subject: [PATCH 04/24] further code cleanup --- lib_dec/ivas_lfe_plc.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index e4bbe578d7..e407042075 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -96,6 +96,7 @@ static int16_t lfeplc_lev_dur( err = r[0] + r[1] * rc[0]; memcpy(a_out, a, sizeof(a)); + memset(epsP, 0, sizeof(*epsP) * LFE_PLC_LPCORD); if ( epsP != NULL ) { @@ -112,7 +113,7 @@ static int16_t lfeplc_lev_dur( } rc[i - 1] = ( -s ) / err; - if ( fabs( rc[i - 1] ) > 0.99945f ) + if ( fabsf( rc[i - 1] ) > 0.99945f ) { flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ return flag; @@ -283,22 +284,22 @@ static float find_max_delta( if ( !stable ) { - if ( fabs( eps ) > EPS_STOP ) + if ( fabsf( eps ) > EPS_STOP ) { - eps = -fabs( eps ) * fac; + eps = -fabsf( eps ) * fac; } else { - eps = -fabs( eps ); + eps = -fabsf( eps ); } } else { - if ( fabs( eps ) < EPS_STOP ) + if ( fabsf( eps ) < EPS_STOP ) { break; } - eps = fabs( eps ) * fac; + eps = fabsf( eps ) * fac; } } @@ -341,11 +342,20 @@ static void recover_samples( fac *= att; } + printf("LPC filter coefs: %.10f", a[0]); for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) { a[i] = a[i] * fac; fac *= att * ( 1.0f + delta ); + printf(", %.10f", a[i]); } + printf("\n"); + printf("Pred erros: %.10f", pee[0]); + for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) + { + printf(", %.10f", pee[i]); + } + printf("\n"); set_zero( zeroes, LFE_PLC_RECLEN ); syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); -- GitLab From 41baa039b42397b4ade059fb012546d2a6a10b74 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 17 Jul 2024 15:01:38 +1000 Subject: [PATCH 05/24] remove printf statements --- lib_dec/ivas_lfe_plc.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index e407042075..efc242ef3f 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -342,20 +342,11 @@ static void recover_samples( fac *= att; } - printf("LPC filter coefs: %.10f", a[0]); for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) { a[i] = a[i] * fac; fac *= att * ( 1.0f + delta ); - printf(", %.10f", a[i]); } - printf("\n"); - printf("Pred erros: %.10f", pee[0]); - for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) - { - printf(", %.10f", pee[i]); - } - printf("\n"); set_zero( zeroes, LFE_PLC_RECLEN ); syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); -- GitLab From 800f9ba91e0a7ca1529e34df184e2453a25f36ec Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 17 Jul 2024 21:45:18 +1000 Subject: [PATCH 06/24] Add switches, prepare for public release --- lib_com/options.h | 2 + lib_dec/ivas_lfe_plc.c | 446 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 438 insertions(+), 10 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 76b6649a1f..bb194c5244 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -172,6 +172,8 @@ /* all switches in this category should start with "NONBE_" */ #define NON_BE_FIX_1137_GSC_IVAS_FXFLT_DECODING /* VA: Add fix point bit allocation for special GSC mode such that float and fixed point have the same final bit allocation */ + +#define NONE_BE_FIX_816_LFE_PLC_FLOAT /* DLB: issue 816: reduce required precision to float for LFE-PLC*/ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index efc242ef3f..d92af2bf80 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -40,7 +40,9 @@ #include "debug.h" #endif #include "wmc_auto.h" +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT #include "string.h" +#endif /*------------------------------------------------------------------------------------------* * Local constants @@ -53,20 +55,17 @@ #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT #define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ - #define MAX_LEN_LP 960 - #define EPS_STOP 1e-5f +#else +#define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ +#define MAX_LEN_LP 960 +#define EPS_STOP 1e-5 +#endif -/*------------------------------------------------------------------------------------------* - * Static function declarations - * - * Note (DLB): the local float precision functions defined below are replica of corresponding - * float functions defined in tools.c, lpc_tools.c and syn_filt.c. - * float precision arithmetic is required for proper functioning of the lfe_plc. - *------------------------------------------------------------------------------------------*/ - +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT /*---------------------------------------------------------------------* * lev_dur() * @@ -353,8 +352,431 @@ static void recover_samples( return; } +#else +/*------------------------------------------------------------------------------------------* + * Static function declarations + * + * Note (DLB): the local double precision functions defined below are replica of corresponding + * float functions defined in tools.c, lpc_tools.c and syn_filt.c. + * Double precision arithmetic is required for proper functioning of the lfe_plc. + *------------------------------------------------------------------------------------------*/ + +static void mvr2d( + const float x[], /* i : input vector */ + double y[], /* o : output vector */ + const int16_t n /* i : vector size */ +) +{ + int16_t i; + + if ( n <= 0 ) + { + /* cannot transfer vectors with size 0 */ + return; + } + + for ( i = n - 1; i >= 0; i-- ) + { + y[i] = x[i]; + } + + return; +} + + +/*---------------------------------------------------------------------* + * autocorr() + * + * Compute autocorrelations of input signal + *---------------------------------------------------------------------*/ + +static void d_autocorr( + const double *x, /* i : input signal */ + double *r, /* o : autocorrelations vector */ + const int16_t m, /* i : order of LP filter */ + const int16_t len, /* i : window size */ + const double *wind, /* i : window */ + const int16_t rev_flag, /* i : flag to reverse window */ + const int16_t sym_flag, /* i : symmetric window flag */ + const int16_t no_thr /* i : flag to avoid thresholding */ +) +{ + double t[MAX_LEN_LP]; + double s; + int16_t i, j; + + /* Windowing of signal */ + if ( rev_flag == 1 ) + { + /* time reversed window */ + for ( i = 0; i < len; i++ ) + { + t[i] = x[i] * wind[len - i - 1]; + } + } + else if ( sym_flag == 1 ) + { + /* symmetric window of even length */ + for ( i = 0; i < len / 2; i++ ) + { + t[i] = x[i] * wind[i]; + } + + for ( ; i < len; i++ ) + { + t[i] = x[i] * wind[len - 1 - i]; + } + } + else /* assymetric window */ + { + for ( i = 0; i < len; i++ ) + { + t[i] = x[i] * wind[i]; + } + } + + /* Compute r[1] to r[m] */ + for ( i = 0; i <= m; i++ ) + { + s = t[0] * t[i]; + for ( j = 1; j < len - i; j++ ) + { + s += t[j] * t[i + j]; + } + r[i] = s; + } + + if ( r[0] < 100.0f && no_thr == 0 ) + { + r[0] = 100.0f; + } + + return; +} + + +/*---------------------------------------------------------------------* + * lev_dur() + * + * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations + * of input signal + *---------------------------------------------------------------------*/ + +/*! r: energy of prediction error */ +static int16_t d_lev_dur( + double *a, /* o : LP coefficients (a[0] = 1.0) */ + const double *r, /* i : vector of autocorrelations */ + const int16_t m, /* i : order of LP filter */ + double epsP[] /* o : prediction error energy */ +) +{ + int16_t i, j, l; + double buf[TCXLTP_LTP_ORDER]; + double *rc; /* reflection coefficients 0,...,m-1 */ + double s, at, err; + int16_t flag = 0; + + rc = &buf[0]; + rc[0] = ( -r[1] ) / r[0]; + a[0] = 1.0; + a[1] = rc[0]; + err = r[0] + r[1] * rc[0]; + + if ( epsP != NULL ) + { + epsP[0] = r[0]; + epsP[1] = err; + } + + for ( i = 2; i <= m; i++ ) + { + s = 0.0; + for ( j = 0; j < i; j++ ) + { + s += r[i - j] * a[j]; + } + + rc[i - 1] = ( -s ) / err; + if ( fabs( rc[i - 1] ) > 0.99945f ) + { + flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ + } + for ( j = 1; j <= i / 2; j++ ) + { + l = i - j; + at = a[j] + rc[i - 1] * a[l]; + a[l] += rc[i - 1] * a[j]; + a[j] = at; + } + + a[i] = rc[i - 1]; + + err += rc[i - 1] * s; + + if ( err <= 0.0f ) + { + err = 0.01f; + } + + if ( epsP != NULL ) + { + epsP[i] = err; + } + } + + return ( flag ); +} + +/*-------------------------------------------------------------------* + * a2rc() + * + * Convert from LPC to reflection coeff + *-------------------------------------------------------------------*/ + +static uint16_t d_a2rc( + const double *a, /* i : LPC coefficients */ + double *refl, /* o : Reflection co-efficients */ + const int16_t lpcorder /* i : LPC order */ +) +{ + double ff[LFE_PLC_LPCORD]; + int16_t m, j, n; + double km, denom, x; + + for ( m = 0; m < lpcorder; m++ ) + { + ff[m] = -a[m]; + } + + /* Initialization */ + for ( m = lpcorder - 1; m >= 0; m-- ) + { + km = ff[m]; + if ( km <= -1.0 || km >= 1.0 ) + { + for ( j = 0; j < lpcorder; j++ ) + { + refl[j] = 0.0; + } + + return 0; + } + + refl[m] = -km; + denom = 1.0 / ( 1.0 - km * km ); + for ( j = 0; j < m / 2; j++ ) + { + n = m - 1 - j; + x = denom * ff[j] + km * denom * ff[n]; + ff[n] = denom * ff[n] + km * denom * ff[j]; + ff[j] = x; + } + + if ( m & 1 ) + { + ff[j] = denom * ff[j] + km * denom * ff[j]; + } + } + + return 1; +} + + +static void d_syn_filt( + const double 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 */ + const float mem[] /* i : initial filter states */ +) +{ + int16_t i, j; + double buf[LFE_PLC_LPCORD + LFE_PLC_RECLEN]; /* temporary synthesis buffer */ + double s, *yy; + + yy = &buf[0]; + + /*------------------------------------------------------------------* + * copy initial filter states into synthesis buffer and do synthesis + *------------------------------------------------------------------*/ + for ( i = 0; i < m; i++ ) + { + *yy++ = mem[i]; + } + + /*-----------------------------------------------------------------------* + * Do the filtering + *-----------------------------------------------------------------------*/ + + for ( i = 0; i < l; i++ ) + { + s = x[i]; + for ( j = 1; j <= m; j++ ) + { + s -= a[j] * yy[i - j]; + } + + yy[i] = s; + y[i] = (float) s; + } + + return; +} + + +/*-----------------------------------------------------------------------------------------* + * Function check_stab() + * + * LPC filter stability check applying given sharpening value delta + *-----------------------------------------------------------------------------------------*/ + +static uint16_t check_stab( + const double *a, + double delta ) +{ + double amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; + int16_t i; + double fac; + double fac1; + uint16_t stable; + + fac = 1.0 + delta; + fac1 = fac; + + for ( i = 0; i < LFE_PLC_LPCORD; i++ ) + { + amod[i] = a[i] * fac; + fac *= fac1; + } + stable = d_a2rc( amod, refl, LFE_PLC_LPCORD ); + + return stable; +} + + +/*-----------------------------------------------------------------------------------------* + * Function find_max_delta() + * + * Find maximum LPC filter sharpening by iteration to get a filter that is almost instable + *-----------------------------------------------------------------------------------------*/ + +static double find_max_delta( + double *a ) +{ + double delta; + double eps; + uint16_t stable; + double fac; + + delta = 0.0; + eps = 0.01; + fac = 2; + stable = FALSE; + + while ( check_stab( a, eps ) ) + { + + eps *= fac; + stable = TRUE; + } + fac = 0.5; + + if ( stable ) + { + eps *= fac; + } + + while ( !stable ) + { + eps *= fac; + stable = check_stab( a, eps ); + } + + /* must be stable with current eps */ + delta = eps; + eps *= fac; + + while ( 1 ) + { + delta += eps; + stable = check_stab( a, delta ); + + if ( !stable ) + { + if ( fabs( eps ) > EPS_STOP ) + { + eps = -fabs( eps ) * fac; + } + else + { + eps = -fabs( eps ); + } + } + else + { + if ( fabs( eps ) < EPS_STOP ) + { + break; + } + eps = fabs( eps ) * fac; + } + } + + return delta; +} +/*-----------------------------------------------------------------------------------------* + * Function recover_samples() + * + * recover lost samples by extrapolation of signal buffer + *-----------------------------------------------------------------------------------------*/ + +static void recover_samples( + const int16_t bfi_count, + const float *outbuf, + float *rec_frame ) +{ + int16_t i; + float zeroes[LFE_PLC_RECLEN]; + double delta, fac, att; + double d_outbuf[LFE_PLC_BUFLEN], d_r[LFE_PLC_LPCORD + 1], d_a[LFE_PLC_LPCORD + 1], d_pee[LFE_PLC_LPCORD + 1]; + + mvr2d( outbuf, d_outbuf, LFE_PLC_BUFLEN ); + d_autocorr( d_outbuf, d_r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc, 0, 1, 1 ); + + if ( d_r[0] < POW_THR * LFE_PLC_BUFLEN ) + { + set_zero( rec_frame, LFE_PLC_RECLEN ); + return; + } + d_lev_dur( d_a, d_r, LFE_PLC_LPCORD, d_pee ); + + delta = find_max_delta( d_a + 1 ); + + fac = 1.0 + delta; + att = 1.0; + + if ( bfi_count >= LFE_PLC_MUTE_THR ) + { + att = LFE_PLC_BURST_ATT; + fac *= att; + } + + for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) + { + d_a[i] = d_a[i] * fac; + fac *= att * ( 1.0 + delta ); + } + + set_zero( zeroes, LFE_PLC_RECLEN ); + d_syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD ); + + return; +} +#endif + /*-----------------------------------------------------------------------------------------* * Function ivas_lfe_tdplc() * @@ -363,7 +785,11 @@ static void recover_samples( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT float *prevsynth, /* i : previous frame synthesis */ +#else + const float *prevsynth, /* i : previous frame synthesis */ +#endif float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ ) -- GitLab From c948b8bd539815ac4d52ecd0a27a2ed7dbddf16b Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Fri, 19 Jul 2024 09:30:36 +1000 Subject: [PATCH 07/24] replace floor with floorf in ivas_lfe_enc.c --- lib_enc/ivas_lfe_enc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index dafb2cc642..f2fb1fde9a 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -164,7 +164,7 @@ static void ivas_lfe_enc_quant( } else { - shift = (int16_t) floor( IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f( max_value / lfe_abs_sum ) ); + shift = (int16_t) floorf( IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f( max_value / lfe_abs_sum ) ); } shift = max( min_shift * IVAS_LFE_SHIFTS_PER_DOUBLE, min( max_shift, shift ) ); -- GitLab From 8dfc24767b6b83a60eb81006257b2d37a3533213 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Fri, 19 Jul 2024 11:21:50 +1000 Subject: [PATCH 08/24] complete wrapping changed codes in #ifdef blocks --- lib_com/ivas_prot.h | 4 ++++ lib_com/ivas_rom_com.c | 23 +++++++++++++++++++++-- lib_enc/ivas_lfe_enc.c | 4 ++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 63041015fa..824ae20d59 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5493,7 +5493,11 @@ void ivas_lfe_dec( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT float *prevsynth, /* i : previous frame synthesis */ +#else + double *prevsynth, /* i : previous frame synthesis */ +#endif float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ ); diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index bf2d962d3c..8d15b0e2a6 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3129,6 +3129,7 @@ const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; const float ivas_lfe_lpf_delay[2] = { 0.00175f, 0.0035f }; +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT const float hamm_lfe_plc[LFE_PLC_LENANA / 2] = { 0.08000000000000002f, 0.08015895227847719f, 0.08063569926248770f, 0.08142991147368656f, 0.08254104003450596f, 0.08396831704748331f, 0.08571075612595230f, 0.08776715307573196f, @@ -3147,8 +3148,26 @@ const float hamm_lfe_plc[LFE_PLC_LENANA / 2] = 0.96233504613317988f, 0.96698111571154954f, 0.97133209998031445f, 0.97538499198789563f, 0.97913699079334116f, 0.98258550340204664f, 0.98572814655776630f, 0.98856274838967395f, 0.99108734991333569f, 0.99330020638455863f, 0.99519978850517732f, 0.99678478347994692f, 0.99805409592381300f, 0.99900684861892730f, 0.99964238312089115f, 0.99996026021380402f }; - - +#else +const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = +{ + 0.08000000000000002, 0.08015895227847719, 0.08063569926248770, 0.08142991147368656, 0.08254104003450596, 0.08396831704748331, 0.08571075612595230, 0.08776715307573196, + 0.09013608672734141, 0.09281591991816535, 0.09580480062389246, 0.09910066323844335, 0.10270123000150438, 0.10660401257268071, 0.11080631375118072, 0.11530522933984272, + 0.12009765015221685, 0.12518026416131367, 0.13054955878853602, 0.13620182333121073, 0.14213315152704381, 0.14833944425372619, 0.15481641236182375, 0.16155957963899570, + 0.16856428590349043, 0.17582569022478273, 0.18333877426912554, 0.19109834576770490, 0.19909904210500018, 0.20733533402487142, 0.21580152945181053, 0.22449177742471671, + 0.23340007214047787, 0.24252025710456171, 0.25184602938575001, 0.26137094397207467, 0.27108841822494550, 0.28099173642839037, 0.29107405443026624, 0.30132840437223085, + 0.31174769950520753, 0.32232473908701620, 0.33305221335878232, 0.34392270859668939, 0.35492871223557998, 0.36606261806086549, 0.37731673146515798, 0.38868327476598852, + 0.40015439258093899, 0.41172215725647360, 0.42337857434671339, 0.43511558813837425, 0.44692508721804453, 0.45879891007795709, 0.47072885075638249, 0.48270666450874267, + 0.49472407350552849, 0.50677277255308162, 0.51884443483328757, 0.53093071765821398, 0.54302326823571601, 0.55511372944202464, 0.56719374559732838, 0.57925496824035816, + 0.59128906189798180, 0.60328770984582458, 0.61524261985593010, 0.62714552992749328, 0.63898821399670414, 0.65076248762175315, 0.66246021363907504, 0.67407330778691554, + 0.68559374429233988, 0.69701356141781945, 0.70832486696356345, 0.71951984372179334, 0.73059075487919101, 0.74152994936378558, 0.75232986713258543, 0.76298304439630038, + 0.77348211877754336, 0.78381983439894576, 0.79398904689767136, 0.80398272836286389, 0.81379397219261318, 0.82341599786708708, 0.83284215563452701, 0.84206593110687011, + 0.85108094976182280, 0.85988098134827329, 0.86845994419199846, 0.87681190939868969, 0.88493110495139349, 0.89281191969953333, 0.90044890723675941, 0.90783678966494241, + 0.91497046124171255, 0.92184499190902180, 0.92845563070029180, 0.93479780902379184, 0.94086714381997805, 0.94665944059061280, 0.95217069629756890, 0.95739710212931617, + 0.96233504613317988, 0.96698111571154954, 0.97133209998031445, 0.97538499198789563, 0.97913699079334116, 0.98258550340204664, 0.98572814655776630, 0.98856274838967395, + 0.99108734991333569, 0.99330020638455863, 0.99519978850517732, 0.99678478347994692, 0.99805409592381300, 0.99900684861892730, 0.99964238312089115, 0.99996026021380402 +}; +#endif /*------------------------------------------------------------------------------------------* * MDFT/iMDFT ROM tables *------------------------------------------------------------------------------------------*/ diff --git a/lib_enc/ivas_lfe_enc.c b/lib_enc/ivas_lfe_enc.c index f2fb1fde9a..18e68b709d 100644 --- a/lib_enc/ivas_lfe_enc.c +++ b/lib_enc/ivas_lfe_enc.c @@ -164,7 +164,11 @@ static void ivas_lfe_enc_quant( } else { +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT shift = (int16_t) floorf( IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f( max_value / lfe_abs_sum ) ); +#else + shift = (int16_t) floor( IVAS_LFE_SHIFTS_PER_DOUBLE * log2_f( max_value / lfe_abs_sum ) ); +#endif } shift = max( min_shift * IVAS_LFE_SHIFTS_PER_DOUBLE, min( max_shift, shift ) ); -- GitLab From 80790586b6c6b7cc8a77ecbe999e18734d781999 Mon Sep 17 00:00:00 2001 From: Jiaquan Huo Date: Mon, 22 Jul 2024 00:18:31 +0000 Subject: [PATCH 09/24] cleanup unused variables --- lib_dec/ivas_lfe_plc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index d92af2bf80..c61cb8b3ab 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -50,14 +50,12 @@ #define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) #define LFE_PLC_LPCORD ( 20 ) -#define LFE_PLC_MAXITER ( 10 ) #define POW_THR ( 1.0e-8f ) #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT #define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -#define MAX_LEN_LP 960 #define EPS_STOP 1e-5f #else #define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -- GitLab From ce41f41a96d864f7a3765d8dec81c6bf46ee03f1 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Thu, 25 Jul 2024 16:57:59 +1000 Subject: [PATCH 10/24] Further cleanup to highlight the changes --- lib_dec/ivas_lfe_plc.c | 481 +++++++++++++++-------------------------- 1 file changed, 177 insertions(+), 304 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index c61cb8b3ab..508da1da44 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -40,9 +40,6 @@ #include "debug.h" #endif #include "wmc_auto.h" -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT -#include "string.h" -#endif /*------------------------------------------------------------------------------------------* * Local constants @@ -63,294 +60,7 @@ #define EPS_STOP 1e-5 #endif -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT -/*---------------------------------------------------------------------* - * lev_dur() - * - * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations - * of input signal - *---------------------------------------------------------------------*/ - -/*! r: energy of prediction error */ -static int16_t lfeplc_lev_dur( - float *a_out, /* o : LP coefficients (a[0] = 1.0) */ - const float *r, /* i : vector of autocorrelations */ - const int16_t m, /* i : order of LP filter */ - float epsP[] /* o : prediction error energy */ -) -{ - int16_t i, j, l; - float buf[TCXLTP_LTP_ORDER]; - float *rc; /* reflection coefficients 0,...,m-1 */ - float s, at, err; - int16_t flag = 0; - float a[LFE_PLC_LPCORD + 1] = {0.f}; - - rc = &buf[0]; - rc[0] = ( -r[1] ) / r[0]; - a[0] = 1.0f; - a[1] = rc[0]; - err = r[0] + r[1] * rc[0]; - - memcpy(a_out, a, sizeof(a)); - memset(epsP, 0, sizeof(*epsP) * LFE_PLC_LPCORD); - - if ( epsP != NULL ) - { - epsP[0] = r[0]; - epsP[1] = err; - } - - for ( i = 2; i <= m; i++ ) - { - s = 0.0f; - for ( j = 0; j < i; j++ ) - { - s += r[i - j] * a[j]; - } - - rc[i - 1] = ( -s ) / err; - if ( fabsf( rc[i - 1] ) > 0.99945f ) - { - flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ - return flag; - } - else - { - for (j = 0; j <= m; j++) - { - a_out[j] = a[j]; - } - } - for ( j = 1; j <= i / 2; j++ ) - { - l = i - j; - at = a[j] + rc[i - 1] * a[l]; - a[l] += rc[i - 1] * a[j]; - a[j] = at; - } - - a[i] = rc[i - 1]; - - err += rc[i - 1] * s; - - if ( err <= 0.0f ) - { - err = 0.01f; - } - - if ( epsP != NULL ) - { - epsP[i] = err; - } - } - - return ( flag ); -} - -/*-------------------------------------------------------------------* - * a2rc() - * - * Convert from LPC to reflection coeff - *-------------------------------------------------------------------*/ - -static uint16_t lfeplc_a2rc( - const float *a, /* i : LPC coefficients */ - float *refl, /* o : Reflection co-efficients */ - const int16_t lpcorder /* i : LPC order */ -) -{ - float ff[LFE_PLC_LPCORD]; - int16_t m, j, n; - float km, denom, x; - - for ( m = 0; m < lpcorder; m++ ) - { - ff[m] = -a[m]; - } - - /* Initialization */ - for ( m = lpcorder - 1; m >= 0; m-- ) - { - km = ff[m]; - if ( km <= -1.0f || km >= 1.0f ) - { - for ( j = 0; j < lpcorder; j++ ) - { - refl[j] = 0.0f; - } - - return 0; - } - - refl[m] = -km; - denom = 1.0f / ( 1.0f - km * km ); - for ( j = 0; j < m / 2; j++ ) - { - n = m - 1 - j; - x = denom * ff[j] + km * denom * ff[n]; - ff[n] = denom * ff[n] + km * denom * ff[j]; - ff[j] = x; - } - - if ( m & 1 ) - { - ff[j] = denom * ff[j] + km * denom * ff[j]; - } - } - - return 1; -} - -/*-----------------------------------------------------------------------------------------* - * Function check_stab() - * - * LPC filter stability check applying given sharpening value delta - *-----------------------------------------------------------------------------------------*/ - -static uint16_t check_stab( - const float *a, - float delta ) -{ - float amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; - int16_t i; - float fac; - float fac1; - uint16_t stable; - - fac = 1.0f + delta; - fac1 = fac; - - for ( i = 0; i < LFE_PLC_LPCORD; i++ ) - { - amod[i] = a[i] * fac; - fac *= fac1; - } - stable = lfeplc_a2rc( amod, refl, LFE_PLC_LPCORD ); - - return stable; -} - - -/*-----------------------------------------------------------------------------------------* - * Function find_max_delta() - * - * Find maximum LPC filter sharpening by iteration to get a filter that is almost instable - *-----------------------------------------------------------------------------------------*/ - -static float find_max_delta( - float *a ) -{ - float delta; - float eps; - uint16_t stable; - float fac; - - delta = 0.0f; - eps = 0.01f; - fac = 2; - stable = FALSE; - - while ( check_stab( a, eps ) ) - { - - eps *= fac; - stable = TRUE; - } - fac = 0.5f; - - if ( stable ) - { - eps *= fac; - } - - while ( !stable ) - { - eps *= fac; - stable = check_stab( a, eps ); - } - - /* must be stable with current eps */ - delta = eps; - eps *= fac; - - while ( 1 ) - { - delta += eps; - stable = check_stab( a, delta ); - - if ( !stable ) - { - if ( fabsf( eps ) > EPS_STOP ) - { - eps = -fabsf( eps ) * fac; - } - else - { - eps = -fabsf( eps ); - } - } - else - { - if ( fabsf( eps ) < EPS_STOP ) - { - break; - } - eps = fabsf( eps ) * fac; - } - } - - return delta; -} - - -/*-----------------------------------------------------------------------------------------* - * Function recover_samples() - * - * recover lost samples by extrapolation of signal buffer - *-----------------------------------------------------------------------------------------*/ - -static void recover_samples( - const int16_t bfi_count, - float *outbuf, - float *rec_frame ) -{ - int16_t i; - float zeroes[LFE_PLC_RECLEN]; - float delta, fac, att; - float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1], pee[LFE_PLC_LPCORD + 1]; - autocorr(outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); - - if ( r[0] < POW_THR * LFE_PLC_BUFLEN ) - { - set_zero( rec_frame, LFE_PLC_RECLEN ); - return; - } - lfeplc_lev_dur( a, r, LFE_PLC_LPCORD, pee ); - - delta = find_max_delta( a + 1 ); - - fac = 1.0f + delta; - att = 1.0f; - - if ( bfi_count >= LFE_PLC_MUTE_THR ) - { - att = LFE_PLC_BURST_ATT; - fac *= att; - } - - for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) - { - a[i] = a[i] * fac; - fac *= att * ( 1.0f + delta ); - } - - set_zero( zeroes, LFE_PLC_RECLEN ); - syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); - - return; -} -#else +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT /*------------------------------------------------------------------------------------------* * Static function declarations * @@ -467,11 +177,34 @@ static int16_t d_lev_dur( const int16_t m, /* i : order of LP filter */ double epsP[] /* o : prediction error energy */ ) +#else +/*---------------------------------------------------------------------* + * lev_dur() + * + * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations + * of input signal + *---------------------------------------------------------------------*/ + +/*! r: energy of prediction error */ +static int16_t lfeplc_lev_dur( + float *a_out, /* o : LP coefficients (a[0] = 1.0) */ + const float *r, /* i : vector of autocorrelations */ + const int16_t m, /* i : order of LP filter */ + float epsP[] /* o : prediction error energy */ +) +#endif { int16_t i, j, l; +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT double buf[TCXLTP_LTP_ORDER]; double *rc; /* reflection coefficients 0,...,m-1 */ double s, at, err; +#else + float buf[TCXLTP_LTP_ORDER]; + float *rc; /* reflection coefficients 0,...,m-1 */ + float s, at, err; + float a[LFE_PLC_LPCORD + 1] = {0.f}; +#endif int16_t flag = 0; rc = &buf[0]; @@ -480,6 +213,14 @@ static int16_t d_lev_dur( a[1] = rc[0]; err = r[0] + r[1] * rc[0]; +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT + for (i = 0; i <= LFE_PLC_LPCORD; i++) + { + a_out[i] = 0.f; + epsP[i] = 0.f; + } +#endif + if ( epsP != NULL ) { epsP[0] = r[0]; @@ -488,17 +229,37 @@ static int16_t d_lev_dur( for ( i = 2; i <= m; i++ ) { +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT s = 0.0; +#else + s = 0.0f; +#endif for ( j = 0; j < i; j++ ) { s += r[i - j] * a[j]; } rc[i - 1] = ( -s ) / err; +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( fabs( rc[i - 1] ) > 0.99945f ) +#else + if ( fabsf( rc[i - 1] ) > 0.99945f ) +#endif { flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT } +#else + return flag; + } + else + { + for (j = 0; j <=m; j++) + { + a_out[j] = a[j]; + } + } +#endif for ( j = 1; j <= i / 2; j++ ) { l = i - j; @@ -530,16 +291,28 @@ static int16_t d_lev_dur( * * Convert from LPC to reflection coeff *-------------------------------------------------------------------*/ - +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static uint16_t d_a2rc( const double *a, /* i : LPC coefficients */ double *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ ) +#else +static uint16_t lfeplc_a2rc( + const float *a, /* i : LPC coefficients */ + float *refl, /* o : Reflection co-efficients */ + const int16_t lpcorder /* i : LPC order */ +) +#endif { +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT double ff[LFE_PLC_LPCORD]; - int16_t m, j, n; double km, denom, x; +#else + float ff[LFE_PLC_LPCORD]; + float km, denom, x; +#endif + int16_t m, j, n; for ( m = 0; m < lpcorder; m++ ) { @@ -550,18 +323,30 @@ static uint16_t d_a2rc( for ( m = lpcorder - 1; m >= 0; m-- ) { km = ff[m]; +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( km <= -1.0 || km >= 1.0 ) +#else + if ( km <= -1.0f || km >= 1.0f ) +#endif { for ( j = 0; j < lpcorder; j++ ) { +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT refl[j] = 0.0; +#else + refl[j] = 0.0f; +#endif } return 0; } refl[m] = -km; +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT denom = 1.0 / ( 1.0 - km * km ); +#else + denom = 1.0f / ( 1.0f - km * km ); +#endif for ( j = 0; j < m / 2; j++ ) { n = m - 1 - j; @@ -579,7 +364,7 @@ static uint16_t d_a2rc( return 1; } - +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static void d_syn_filt( const double a[], /* i : LP filter coefficients */ const int16_t m, /* i : order of LP filter */ @@ -621,25 +406,38 @@ static void d_syn_filt( return; } - +#endif /*-----------------------------------------------------------------------------------------* * Function check_stab() * * LPC filter stability check applying given sharpening value delta *-----------------------------------------------------------------------------------------*/ - +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static uint16_t check_stab( const double *a, double delta ) { double amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; - int16_t i; double fac; double fac1; +#else +static uint16_t check_stab( + const float *a, + float delta ) +{ + float amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; + float fac; + float fac1; +#endif + int16_t i; uint16_t stable; +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT fac = 1.0 + delta; +#else + fac = 1.0f + delta; +#endif fac1 = fac; for ( i = 0; i < LFE_PLC_LPCORD; i++ ) @@ -647,7 +445,11 @@ static uint16_t check_stab( amod[i] = a[i] * fac; fac *= fac1; } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT stable = d_a2rc( amod, refl, LFE_PLC_LPCORD ); +#else + stable = lfeplc_a2rc( amod, refl, LFE_PLC_LPCORD ); +#endif return stable; } @@ -658,17 +460,30 @@ static uint16_t check_stab( * * Find maximum LPC filter sharpening by iteration to get a filter that is almost instable *-----------------------------------------------------------------------------------------*/ - +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static double find_max_delta( double *a ) { double delta; double eps; - uint16_t stable; double fac; +#else +static float find_max_delta( + float *a ) +{ + float delta; + float eps; + float fac; +#endif + uint16_t stable; +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT delta = 0.0; eps = 0.01; +#else + delta = 0.0f; + eps = 0.01f; +#endif fac = 2; stable = FALSE; @@ -678,7 +493,11 @@ static double find_max_delta( eps *= fac; stable = TRUE; } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT fac = 0.5; +#else + fac = 0.5f; +#endif if ( stable ) { @@ -700,6 +519,7 @@ static double find_max_delta( delta += eps; stable = check_stab( a, delta ); +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( !stable ) { if ( fabs( eps ) > EPS_STOP ) @@ -719,6 +539,27 @@ static double find_max_delta( } eps = fabs( eps ) * fac; } +#else + if ( !stable ) + { + if ( fabsf( eps ) > EPS_STOP ) + { + eps = -fabsf( eps ) * fac; + } + else + { + eps = -fabsf( eps ); + } + } + else + { + if ( fabsf( eps ) < EPS_STOP ) + { + break; + } + eps = fabsf( eps ) * fac; + } +#endif } return delta; @@ -730,31 +571,55 @@ static double find_max_delta( * * recover lost samples by extrapolation of signal buffer *-----------------------------------------------------------------------------------------*/ - static void recover_samples( const int16_t bfi_count, +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT const float *outbuf, +#else + float *outbuf, +#endif float *rec_frame ) { int16_t i; float zeroes[LFE_PLC_RECLEN]; +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT double delta, fac, att; double d_outbuf[LFE_PLC_BUFLEN], d_r[LFE_PLC_LPCORD + 1], d_a[LFE_PLC_LPCORD + 1], d_pee[LFE_PLC_LPCORD + 1]; + mvr2d( outbuf, d_outbuf, LFE_PLC_BUFLEN ); d_autocorr( d_outbuf, d_r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc, 0, 1, 1 ); +#else + float delta, fac, att; + float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1], pee[LFE_PLC_LPCORD + 1]; + + autocorr(outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); +#endif +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( d_r[0] < POW_THR * LFE_PLC_BUFLEN ) +#else + if ( r[0] < POW_THR * LFE_PLC_BUFLEN ) +#endif { set_zero( rec_frame, LFE_PLC_RECLEN ); return; } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT d_lev_dur( d_a, d_r, LFE_PLC_LPCORD, d_pee ); delta = find_max_delta( d_a + 1 ); fac = 1.0 + delta; att = 1.0; +#else + lfeplc_lev_dur( a, r, LFE_PLC_LPCORD, pee ); + + delta = find_max_delta( a + 1 ); + + fac = 1.0f + delta; + att = 1.0f; +#endif if ( bfi_count >= LFE_PLC_MUTE_THR ) { @@ -764,16 +629,24 @@ static void recover_samples( for ( i = 1; i <= LFE_PLC_LPCORD; i++ ) { +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT d_a[i] = d_a[i] * fac; fac *= att * ( 1.0 + delta ); +#else + a[i] = a[i] * fac; + fac *= att * ( 1.0f + delta ); +#endif } set_zero( zeroes, LFE_PLC_RECLEN ); +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT d_syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD ); - +#else + syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0); +#endif return; } -#endif + /*-----------------------------------------------------------------------------------------* * Function ivas_lfe_tdplc() @@ -784,9 +657,9 @@ static void recover_samples( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT - float *prevsynth, /* i : previous frame synthesis */ + float *prevsynth, /* i : previous frame synthesis */ #else - const float *prevsynth, /* i : previous frame synthesis */ + double *prevsynth, /* i : previous frame synthesis */ #endif float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ -- GitLab From f56931f879714a70f8a1b9a92c7687b4e801cad9 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Tue, 30 Jul 2024 11:58:55 +1000 Subject: [PATCH 11/24] clang format fix --- lib_dec/ivas_lfe_plc.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 508da1da44..edc2591e2b 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -52,12 +52,12 @@ #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) #define LFE_PLC_MUTE_THR ( 10 ) #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT -#define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -#define EPS_STOP 1e-5f +#define LFE_PLC_BURST_ATT ( powf( powf( 10.0f, -3.0f / 20.0f ), 1.0f / ( LFE_PLC_FS * 20 / 1000 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ +#define EPS_STOP 1e-5f #else -#define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ -#define MAX_LEN_LP 960 -#define EPS_STOP 1e-5 +#define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ +#define MAX_LEN_LP 960 +#define EPS_STOP 1e-5 #endif #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT @@ -187,10 +187,10 @@ static int16_t d_lev_dur( /*! r: energy of prediction error */ static int16_t lfeplc_lev_dur( - float *a_out, /* o : LP coefficients (a[0] = 1.0) */ - const float *r, /* i : vector of autocorrelations */ + float *a_out, /* o : LP coefficients (a[0] = 1.0) */ + const float *r, /* i : vector of autocorrelations */ const int16_t m, /* i : order of LP filter */ - float epsP[] /* o : prediction error energy */ + float epsP[] /* o : prediction error energy */ ) #endif { @@ -203,7 +203,7 @@ static int16_t lfeplc_lev_dur( float buf[TCXLTP_LTP_ORDER]; float *rc; /* reflection coefficients 0,...,m-1 */ float s, at, err; - float a[LFE_PLC_LPCORD + 1] = {0.f}; + float a[LFE_PLC_LPCORD + 1] = { 0.f }; #endif int16_t flag = 0; @@ -214,7 +214,7 @@ static int16_t lfeplc_lev_dur( err = r[0] + r[1] * rc[0]; #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT - for (i = 0; i <= LFE_PLC_LPCORD; i++) + for ( i = 0; i <= LFE_PLC_LPCORD; i++ ) { a_out[i] = 0.f; epsP[i] = 0.f; @@ -254,7 +254,7 @@ static int16_t lfeplc_lev_dur( } else { - for (j = 0; j <=m; j++) + for ( j = 0; j <= m; j++ ) { a_out[j] = a[j]; } @@ -299,8 +299,8 @@ static uint16_t d_a2rc( ) #else static uint16_t lfeplc_a2rc( - const float *a, /* i : LPC coefficients */ - float *refl, /* o : Reflection co-efficients */ + const float *a, /* i : LPC coefficients */ + float *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ ) #endif @@ -593,7 +593,7 @@ static void recover_samples( float delta, fac, att; float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1], pee[LFE_PLC_LPCORD + 1]; - autocorr(outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); + autocorr( outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); #endif #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT @@ -642,7 +642,7 @@ static void recover_samples( #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT d_syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD ); #else - syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0); + syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); #endif return; } @@ -655,11 +655,11 @@ static void recover_samples( *-----------------------------------------------------------------------------------------*/ void ivas_lfe_tdplc( - LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ + LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT - float *prevsynth, /* i : previous frame synthesis */ + float *prevsynth, /* i : previous frame synthesis */ #else - double *prevsynth, /* i : previous frame synthesis */ + double *prevsynth, /* i : previous frame synthesis */ #endif float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ -- GitLab From 9921cbec4f4cad368d60a7d51fbc3b6c7376b4fd Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Tue, 30 Jul 2024 21:25:58 +1000 Subject: [PATCH 12/24] replace lfeplc_a2rc with a2rc --- lib_com/lsf_tools.c | 14 ++++++++++++-- lib_com/prot.h | 4 ++++ lib_dec/ivas_lfe_plc.c | 29 ++--------------------------- lib_dec/swb_tbe_dec.c | 4 ++++ lib_enc/swb_tbe_enc.c | 5 ++++- lib_enc/vad_param_updt.c | 5 ++++- 6 files changed, 30 insertions(+), 31 deletions(-) diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 6311598574..122df43ccd 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -959,8 +959,11 @@ void isp2isf( * * Convert from LPC to reflection coeff *-------------------------------------------------------------------*/ - +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT void a2rc( +#else +int a2rc( +#endif const float *a, /* i : LPC coefficients */ float *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ @@ -985,8 +988,11 @@ void a2rc( { refl[j] = 0.f; } - +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT return; +#else + return 0; +#endif } refl[m] = -km; @@ -1006,7 +1012,11 @@ void a2rc( } } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT return; +#else + return 0; +#endif } diff --git a/lib_com/prot.h b/lib_com/prot.h index d26a2a42ab..f22020ba68 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2998,7 +2998,11 @@ void a2isf( const float *old_isf, const int16_t lpcOrder ); +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT void a2rc( +#else +int a2rc( +#endif const float *a, /* i : LPC coefficients */ float *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index edc2591e2b..dcef0c84f9 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -286,32 +286,20 @@ static int16_t lfeplc_lev_dur( return ( flag ); } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT /*-------------------------------------------------------------------* * a2rc() * * Convert from LPC to reflection coeff *-------------------------------------------------------------------*/ -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static uint16_t d_a2rc( const double *a, /* i : LPC coefficients */ double *refl, /* o : Reflection co-efficients */ const int16_t lpcorder /* i : LPC order */ ) -#else -static uint16_t lfeplc_a2rc( - const float *a, /* i : LPC coefficients */ - float *refl, /* o : Reflection co-efficients */ - const int16_t lpcorder /* i : LPC order */ -) -#endif { -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT double ff[LFE_PLC_LPCORD]; double km, denom, x; -#else - float ff[LFE_PLC_LPCORD]; - float km, denom, x; -#endif int16_t m, j, n; for ( m = 0; m < lpcorder; m++ ) @@ -323,30 +311,18 @@ static uint16_t lfeplc_a2rc( for ( m = lpcorder - 1; m >= 0; m-- ) { km = ff[m]; -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( km <= -1.0 || km >= 1.0 ) -#else - if ( km <= -1.0f || km >= 1.0f ) -#endif { for ( j = 0; j < lpcorder; j++ ) { -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT refl[j] = 0.0; -#else - refl[j] = 0.0f; -#endif } return 0; } refl[m] = -km; -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT denom = 1.0 / ( 1.0 - km * km ); -#else - denom = 1.0f / ( 1.0f - km * km ); -#endif for ( j = 0; j < m / 2; j++ ) { n = m - 1 - j; @@ -364,7 +340,6 @@ static uint16_t lfeplc_a2rc( return 1; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static void d_syn_filt( const double a[], /* i : LP filter coefficients */ const int16_t m, /* i : order of LP filter */ @@ -448,7 +423,7 @@ static uint16_t check_stab( #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT stable = d_a2rc( amod, refl, LFE_PLC_LPCORD ); #else - stable = lfeplc_a2rc( amod, refl, LFE_PLC_LPCORD ); + stable = a2rc( amod, refl, LFE_PLC_LPCORD ); #endif return stable; diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 5f2978157d..c7e076b3ee 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -933,7 +933,11 @@ void swb_tbe_dec( lsf_diff[i] = lsf_shb[i] - lsf_shb[i - 1]; } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); +#else + (void) a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); +#endif tilt_para = 6.6956f * ( 1.0f + refl[0] ) * ( 1.0f + refl[0] ) - 3.8714f * ( 1.0f + refl[0] ) + 1.3041f; if ( st->last_extl != SWB_TBE && st->last_extl != FB_TBE ) { diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 8f93f4241e..613b7d620e 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -795,8 +795,11 @@ void swb_tbe_enc( { lsf_diff[i] = lsf_shb[i] - lsf_shb[i - 1]; } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); - +#else + (void) a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); +#endif /* LSP interpolation for 13.2 kbps and 16.4 kbps */ tilt_para = 6.6956f * ( 1.0f + refl[0] ) * ( 1.0f + refl[0] ) - 3.8714f * ( 1.0f + refl[0] ) + 1.3041f; if ( st->last_extl != SWB_TBE ) diff --git a/lib_enc/vad_param_updt.c b/lib_enc/vad_param_updt.c index 9a12b41373..a14bd88dba 100644 --- a/lib_enc/vad_param_updt.c +++ b/lib_enc/vad_param_updt.c @@ -117,8 +117,11 @@ void vad_param_updt( if ( hVAD->consec_inactive == 5 ) { /* compute spectral tilt parameter */ +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT a2rc( &A[1], refl, M ); - +#else + (void) a2rc( &A[1], refl, M ); +#endif if ( hVAD->spectral_tilt_reset == 1 ) { hVAD->spectral_tilt_reset = 0; -- GitLab From 39cdb09a0ca71f2f4410967de6ba51ab8bcf8150 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 31 Jul 2024 10:44:07 +1000 Subject: [PATCH 13/24] a2rc returning uint16_t instead --- lib_com/lsf_tools.c | 2 +- lib_com/prot.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 122df43ccd..5437a44e51 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -962,7 +962,7 @@ void isp2isf( #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT void a2rc( #else -int a2rc( +uint16_t a2rc( #endif const float *a, /* i : LPC coefficients */ float *refl, /* o : Reflection co-efficients */ diff --git a/lib_com/prot.h b/lib_com/prot.h index f22020ba68..ba09eef8de 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3001,7 +3001,7 @@ void a2isf( #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT void a2rc( #else -int a2rc( +uint16_t a2rc( #endif const float *a, /* i : LPC coefficients */ float *refl, /* o : Reflection co-efficients */ -- GitLab From f95a1865203075052a6fd80195ffa132d92585ba Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 31 Jul 2024 12:31:32 +1000 Subject: [PATCH 14/24] Fix stack corruption in a2rc for LFE PLC --- lib_com/cnst.h | 4 ++++ lib_com/lsf_tools.c | 4 ++++ lib_dec/ivas_lfe_plc.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index ca3c963003..49318b5762 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -563,6 +563,10 @@ enum #define INT_FS_12k8 12800 /* internal sampling frequency */ #define M 16 /* order of the LP filter @ 12.8kHz */ +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT +#define MAX_LP_FILTER_ORDER (20) /* Max order of an LP filter */ +#endif + #define L_FRAME 256 /* frame size at 12.8kHz */ #define NB_SUBFR 4 /* number of subframes per frame */ #define L_SUBFR ( L_FRAME / NB_SUBFR ) /* subframe size */ diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 5437a44e51..8db17d8295 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -969,7 +969,11 @@ uint16_t a2rc( const int16_t lpcorder /* i : LPC order */ ) { +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT float f[M]; +#else + float f[MAX_LP_FILTER_ORDER]; +#endif int16_t m, j, n; float km, denom, x; diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index dcef0c84f9..f49a1dd123 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -46,7 +46,11 @@ *------------------------------------------------------------------------------------------*/ #define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT #define LFE_PLC_LPCORD ( 20 ) +#else +#define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) +#endif #define POW_THR ( 1.0e-8f ) #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) #define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) -- GitLab From 51c28a35bb317177bedeff4a9fb8fedf8de1302d Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 31 Jul 2024 15:09:32 +1000 Subject: [PATCH 15/24] clang format fix --- lib_dec/ivas_lfe_plc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index f49a1dd123..9b1bc12c3c 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -45,11 +45,11 @@ * Local constants *------------------------------------------------------------------------------------------*/ -#define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) +#define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT -#define LFE_PLC_LPCORD ( 20 ) +#define LFE_PLC_LPCORD ( 20 ) #else -#define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) +#define LFE_PLC_LPCORD ( MAX_LP_FILTER_ORDER ) #endif #define POW_THR ( 1.0e-8f ) #define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) -- GitLab From f6a64672d90073e88302d20323f3d50ae0339e51 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 31 Jul 2024 15:19:26 +1000 Subject: [PATCH 16/24] fix a2rc for lfe plc --- lib_com/lsf_tools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 8db17d8295..9af5959c77 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -1019,7 +1019,7 @@ uint16_t a2rc( #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT return; #else - return 0; + return 1; #endif } -- GitLab From f96c9b784ecfe5ddc4eb9129abcee12492ee18b3 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 31 Jul 2024 17:42:10 +1000 Subject: [PATCH 17/24] remove unused array --- lib_dec/ivas_lfe_plc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 9b1bc12c3c..9518798485 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -193,8 +193,7 @@ static int16_t d_lev_dur( static int16_t lfeplc_lev_dur( float *a_out, /* o : LP coefficients (a[0] = 1.0) */ const float *r, /* i : vector of autocorrelations */ - const int16_t m, /* i : order of LP filter */ - float epsP[] /* o : prediction error energy */ + const int16_t m /* i : order of LP filter */ ) #endif { @@ -221,15 +220,16 @@ static int16_t lfeplc_lev_dur( for ( i = 0; i <= LFE_PLC_LPCORD; i++ ) { a_out[i] = 0.f; - epsP[i] = 0.f; } #endif +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( epsP != NULL ) { epsP[0] = r[0]; epsP[1] = err; } +#endif for ( i = 2; i <= m; i++ ) { @@ -281,10 +281,12 @@ static int16_t lfeplc_lev_dur( err = 0.01f; } +#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( epsP != NULL ) { epsP[i] = err; } +#endif } return ( flag ); @@ -570,7 +572,7 @@ static void recover_samples( d_autocorr( d_outbuf, d_r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc, 0, 1, 1 ); #else float delta, fac, att; - float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1], pee[LFE_PLC_LPCORD + 1]; + float r[LFE_PLC_LPCORD + 1], a[LFE_PLC_LPCORD + 1]; autocorr( outbuf, r, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, hamm_lfe_plc, 0, 1, 1 ); #endif @@ -592,7 +594,7 @@ static void recover_samples( fac = 1.0 + delta; att = 1.0; #else - lfeplc_lev_dur( a, r, LFE_PLC_LPCORD, pee ); + lfeplc_lev_dur( a, r, LFE_PLC_LPCORD ); delta = find_max_delta( a + 1 ); -- GitLab From 93695a806e9f76f93b4c38d131547ba96bc4868a Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Wed, 31 Jul 2024 19:05:58 +1000 Subject: [PATCH 18/24] clang format --- lib_dec/ivas_lfe_plc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 9518798485..82a6ec158f 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -191,9 +191,9 @@ static int16_t d_lev_dur( /*! r: energy of prediction error */ static int16_t lfeplc_lev_dur( - float *a_out, /* o : LP coefficients (a[0] = 1.0) */ - const float *r, /* i : vector of autocorrelations */ - const int16_t m /* i : order of LP filter */ + float *a_out, /* o : LP coefficients (a[0] = 1.0) */ + const float *r, /* i : vector of autocorrelations */ + const int16_t m /* i : order of LP filter */ ) #endif { -- GitLab From a4cece7b7c4d75ddcca0bf346718cf7275a352f0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 31 Jul 2024 15:47:05 +0200 Subject: [PATCH 19/24] formal improvements --- lib_com/cnst.h | 2 +- lib_com/ivas_cnst.h | 4 ++++ lib_com/ivas_prot.h | 4 ++-- lib_com/ivas_rom_com.c | 1 + lib_com/ivas_rom_com.h | 4 ++++ lib_com/lpc_tools.c | 2 +- lib_com/lsf_tools.c | 1 + lib_com/prot.h | 1 + lib_dec/ivas_lfe_plc.c | 27 ++++++++++++++++++--------- lib_dec/swb_tbe_dec.c | 5 +---- lib_enc/swb_tbe_enc.c | 6 ++---- lib_enc/vad_param_updt.c | 5 +---- 12 files changed, 37 insertions(+), 25 deletions(-) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 49318b5762..775a8a0e01 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -564,7 +564,7 @@ enum #define INT_FS_12k8 12800 /* internal sampling frequency */ #define M 16 /* order of the LP filter @ 12.8kHz */ #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT -#define MAX_LP_FILTER_ORDER (20) /* Max order of an LP filter */ +#define MAX_LP_FILTER_ORDER 20 /* Max order of an LP filter */ #endif #define L_FRAME 256 /* frame size at 12.8kHz */ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index fbe82c07a2..8c72cf2808 100755 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1444,7 +1444,11 @@ typedef enum /* LFE PLC */ #define LFE_PLC_BUFLEN 240 #define LFE_PLC_FS 1600 +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT +#define L_FRAME_1k6 ( LFE_PLC_FS / FRAMES_PER_SEC ) +#else #define L_FRAME_1k6 ( 20 * LFE_PLC_FS / 1000 ) +#endif #define LFE_PLC_LENANA LFE_PLC_BUFLEN #define LFE_PLC_FDEL 300 diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 3666ef5d15..dc5ef18862 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5497,9 +5497,9 @@ void ivas_lfe_dec( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT - float *prevsynth, /* i : previous frame synthesis */ + float *prevsynth, /* i : previous frame synthesis */ #else - double *prevsynth, /* i : previous frame synthesis */ + double *prevsynth, /* i : previous frame synthesis */ #endif float *ytda, /* o : output time-domain buffer */ const int16_t output_frame /* i : output frame length */ diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 8d15b0e2a6..38991b4039 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3168,6 +3168,7 @@ const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = 0.99108734991333569, 0.99330020638455863, 0.99519978850517732, 0.99678478347994692, 0.99805409592381300, 0.99900684861892730, 0.99964238312089115, 0.99996026021380402 }; #endif + /*------------------------------------------------------------------------------------------* * MDFT/iMDFT ROM tables *------------------------------------------------------------------------------------------*/ diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index c6c8250b03..749ae47b75 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -361,7 +361,11 @@ extern const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP]; extern const ivas_lfe_freq_models ivas_str_lfe_freq_models; extern const float ivas_lfe_lpf_delay[2]; +#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT extern const float hamm_lfe_plc[LFE_PLC_LENANA / 2]; +#else +extern const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2]; +#endif extern const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1]; extern const float ivas_cos_twiddle_480[IVAS_480_PT_LEN >> 1]; diff --git a/lib_com/lpc_tools.c b/lib_com/lpc_tools.c index 9926cd6596..fa3923f8ca 100644 --- a/lib_com/lpc_tools.c +++ b/lib_com/lpc_tools.c @@ -131,7 +131,7 @@ void autocorr( * of input signal *---------------------------------------------------------------------*/ -/*! r: energy of prediction error */ +/*! r: stability flag */ int16_t lev_dur( float *a, /* o : LP coefficients (a[0] = 1.0) */ const float *r, /* i : vector of autocorrelations */ diff --git a/lib_com/lsf_tools.c b/lib_com/lsf_tools.c index 9af5959c77..89963d1df8 100644 --- a/lib_com/lsf_tools.c +++ b/lib_com/lsf_tools.c @@ -962,6 +962,7 @@ void isp2isf( #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT void a2rc( #else +/*! r: stability flag */ uint16_t a2rc( #endif const float *a, /* i : LPC coefficients */ diff --git a/lib_com/prot.h b/lib_com/prot.h index ba09eef8de..4f4222b2f9 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3001,6 +3001,7 @@ void a2isf( #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT void a2rc( #else +/*! r: stability flag */ uint16_t a2rc( #endif const float *a, /* i : LPC coefficients */ diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 82a6ec158f..839276e178 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -64,6 +64,7 @@ #define EPS_STOP 1e-5 #endif + #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT /*------------------------------------------------------------------------------------------* * Static function declarations @@ -183,13 +184,13 @@ static int16_t d_lev_dur( ) #else /*---------------------------------------------------------------------* - * lev_dur() + * lfeplc_lev_dur() * * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations * of input signal *---------------------------------------------------------------------*/ -/*! r: energy of prediction error */ +/*! r: stability flag */ static int16_t lfeplc_lev_dur( float *a_out, /* o : LP coefficients (a[0] = 1.0) */ const float *r, /* i : vector of autocorrelations */ @@ -206,7 +207,7 @@ static int16_t lfeplc_lev_dur( float buf[TCXLTP_LTP_ORDER]; float *rc; /* reflection coefficients 0,...,m-1 */ float s, at, err; - float a[LFE_PLC_LPCORD + 1] = { 0.f }; + float a[LFE_PLC_LPCORD + 1]; #endif int16_t flag = 0; @@ -219,11 +220,10 @@ static int16_t lfeplc_lev_dur( #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT for ( i = 0; i <= LFE_PLC_LPCORD; i++ ) { + a[i] = 0.f; a_out[i] = 0.f; } -#endif - -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT +#else if ( epsP != NULL ) { epsP[0] = r[0]; @@ -244,6 +244,7 @@ static int16_t lfeplc_lev_dur( } rc[i - 1] = ( -s ) / err; + #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( fabs( rc[i - 1] ) > 0.99945f ) #else @@ -264,6 +265,7 @@ static int16_t lfeplc_lev_dur( } } #endif + for ( j = 1; j <= i / 2; j++ ) { l = i - j; @@ -280,8 +282,8 @@ static int16_t lfeplc_lev_dur( { err = 0.01f; } - #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT + if ( epsP != NULL ) { epsP[i] = err; @@ -394,6 +396,7 @@ static void d_syn_filt( * * LPC filter stability check applying given sharpening value delta *-----------------------------------------------------------------------------------------*/ + #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static uint16_t check_stab( const double *a, @@ -405,7 +408,7 @@ static uint16_t check_stab( #else static uint16_t check_stab( const float *a, - float delta ) + const float delta ) { float amod[LFE_PLC_LPCORD], refl[LFE_PLC_LPCORD]; float fac; @@ -426,6 +429,7 @@ static uint16_t check_stab( amod[i] = a[i] * fac; fac *= fac1; } + #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT stable = d_a2rc( amod, refl, LFE_PLC_LPCORD ); #else @@ -441,6 +445,7 @@ static uint16_t check_stab( * * Find maximum LPC filter sharpening by iteration to get a filter that is almost instable *-----------------------------------------------------------------------------------------*/ + #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT static double find_max_delta( double *a ) @@ -552,6 +557,7 @@ static float find_max_delta( * * recover lost samples by extrapolation of signal buffer *-----------------------------------------------------------------------------------------*/ + static void recover_samples( const int16_t bfi_count, #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT @@ -586,6 +592,7 @@ static void recover_samples( set_zero( rec_frame, LFE_PLC_RECLEN ); return; } + #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT d_lev_dur( d_a, d_r, LFE_PLC_LPCORD, d_pee ); @@ -620,11 +627,13 @@ static void recover_samples( } set_zero( zeroes, LFE_PLC_RECLEN ); + #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT d_syn_filt( d_a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD ); #else syn_filt( a, LFE_PLC_LPCORD, zeroes, rec_frame, LFE_PLC_RECLEN, outbuf + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, 0 ); #endif + return; } @@ -638,7 +647,7 @@ static void recover_samples( void ivas_lfe_tdplc( LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT - float *prevsynth, /* i : previous frame synthesis */ + float *prevsynth, /* i : previous frame synthesis */ #else double *prevsynth, /* i : previous frame synthesis */ #endif diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index c7e076b3ee..1d8810c6d9 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -933,11 +933,8 @@ void swb_tbe_dec( lsf_diff[i] = lsf_shb[i] - lsf_shb[i - 1]; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); -#else - (void) a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); -#endif + tilt_para = 6.6956f * ( 1.0f + refl[0] ) * ( 1.0f + refl[0] ) - 3.8714f * ( 1.0f + refl[0] ) + 1.3041f; if ( st->last_extl != SWB_TBE && st->last_extl != FB_TBE ) { diff --git a/lib_enc/swb_tbe_enc.c b/lib_enc/swb_tbe_enc.c index 613b7d620e..3d023d766e 100644 --- a/lib_enc/swb_tbe_enc.c +++ b/lib_enc/swb_tbe_enc.c @@ -795,11 +795,9 @@ void swb_tbe_enc( { lsf_diff[i] = lsf_shb[i] - lsf_shb[i - 1]; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT + a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); -#else - (void) a2rc( hBWE_TD->cur_sub_Aq + 1, refl, M ); -#endif + /* LSP interpolation for 13.2 kbps and 16.4 kbps */ tilt_para = 6.6956f * ( 1.0f + refl[0] ) * ( 1.0f + refl[0] ) - 3.8714f * ( 1.0f + refl[0] ) + 1.3041f; if ( st->last_extl != SWB_TBE ) diff --git a/lib_enc/vad_param_updt.c b/lib_enc/vad_param_updt.c index a14bd88dba..9a12b41373 100644 --- a/lib_enc/vad_param_updt.c +++ b/lib_enc/vad_param_updt.c @@ -117,11 +117,8 @@ void vad_param_updt( if ( hVAD->consec_inactive == 5 ) { /* compute spectral tilt parameter */ -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT a2rc( &A[1], refl, M ); -#else - (void) a2rc( &A[1], refl, M ); -#endif + if ( hVAD->spectral_tilt_reset == 1 ) { hVAD->spectral_tilt_reset = 0; -- GitLab From 3412f68f33ccf4981139d5572e77f258ab259d9f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 31 Jul 2024 16:29:58 +0200 Subject: [PATCH 20/24] fix reset of a[] --- lib_dec/ivas_lfe_plc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 839276e178..45b57d46c5 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -218,11 +218,8 @@ static int16_t lfeplc_lev_dur( err = r[0] + r[1] * rc[0]; #ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT - for ( i = 0; i <= LFE_PLC_LPCORD; i++ ) - { - a[i] = 0.f; - a_out[i] = 0.f; - } + set_f( a_out, 0.f, LFE_PLC_LPCORD + 1 ); + set_f( a + 2, 0.f, LFE_PLC_LPCORD + 1 - 2 ); #else if ( epsP != NULL ) { -- GitLab From 1e92c06db7ebdf76396c48ec49cd5df61b7d02e4 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Sat, 3 Aug 2024 08:37:15 +1000 Subject: [PATCH 21/24] restructure lfeplc_lev_dur main loop --- lib_dec/ivas_lfe_plc.c | 73 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 45b57d46c5..eac405c583 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -64,7 +64,7 @@ #define EPS_STOP 1e-5 #endif - +#if 0 #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT /*------------------------------------------------------------------------------------------* * Static function declarations @@ -290,6 +290,77 @@ static int16_t lfeplc_lev_dur( return ( flag ); } +#else +/*---------------------------------------------------------------------* + * lfeplc_lev_dur() + * + * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations + * of input signal + *---------------------------------------------------------------------*/ + +/*! r: stability flag */ +static int16_t lfeplc_lev_dur( + float *a_out, /* o : LP coefficients (a[0] = 1.0) */ + const float *r, /* i : vector of autocorrelations */ + const int16_t m /* i : order of LP filter */ +) +{ + int16_t i, j, l; + float buf[TCXLTP_LTP_ORDER]; + float *rc; /* reflection coefficients 0,...,m-1 */ + float s, at, err; + float a[LFE_PLC_LPCORD + 1] = { 0.0f }; + + set_f( a_out, 0.f, LFE_PLC_LPCORD + 1); + rc = &buf[0]; + a[0] = 1.f; + err = r[0]; + a_out[0] = a[0]; + rc[0] = ( -r[1] ) / r[0]; + s = r[1]; + a[1] = rc[0]; + a_out[1] = a[1]; + err += rc[0] * s; + s += r[2] * a[1]; + rc[1] = ( -s ) / err; + + i = 2; + while ( i < m ) + { + for ( j = 1; j <= i / 2; j++ ) + { + l = i - j; + at = a[j] + rc[i - 1] * a[l]; + a[l] += rc[i - 1] * a[j]; + a[j] = at; + } + + a[i] = rc[i - 1]; + err += rc[i - 1] * s; + s = 0.f; + i++; + for ( j = 0; j < i; j++ ) + { + s += r[i - j] * a[j]; + } + rc[i - 1] = ( -s ) / err; + if ( fabsf( rc[i - 1] ) > 0.99945f ) + { + return 1; + } + else + { + for ( j = 0; j <= m; j++ ) + { + a_out[j] = a[j]; + } + } + } + + return 0; +} + +#endif #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT /*-------------------------------------------------------------------* -- GitLab From d9fafc1420a48ae153220d0748c4fb904b104b6c Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Sun, 4 Aug 2024 15:27:33 +1000 Subject: [PATCH 22/24] fix bug --- lib_dec/ivas_lfe_plc.c | 55 +----------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index eac405c583..0c358f4233 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -64,7 +64,6 @@ #define EPS_STOP 1e-5 #endif -#if 0 #ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT /*------------------------------------------------------------------------------------------* * Static function declarations @@ -182,33 +181,11 @@ static int16_t d_lev_dur( const int16_t m, /* i : order of LP filter */ double epsP[] /* o : prediction error energy */ ) -#else -/*---------------------------------------------------------------------* - * lfeplc_lev_dur() - * - * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations - * of input signal - *---------------------------------------------------------------------*/ - -/*! r: stability flag */ -static int16_t lfeplc_lev_dur( - float *a_out, /* o : LP coefficients (a[0] = 1.0) */ - const float *r, /* i : vector of autocorrelations */ - const int16_t m /* i : order of LP filter */ -) -#endif { int16_t i, j, l; -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT double buf[TCXLTP_LTP_ORDER]; double *rc; /* reflection coefficients 0,...,m-1 */ double s, at, err; -#else - float buf[TCXLTP_LTP_ORDER]; - float *rc; /* reflection coefficients 0,...,m-1 */ - float s, at, err; - float a[LFE_PLC_LPCORD + 1]; -#endif int16_t flag = 0; rc = &buf[0]; @@ -217,24 +194,15 @@ static int16_t lfeplc_lev_dur( a[1] = rc[0]; err = r[0] + r[1] * rc[0]; -#ifdef NONE_BE_FIX_816_LFE_PLC_FLOAT - set_f( a_out, 0.f, LFE_PLC_LPCORD + 1 ); - set_f( a + 2, 0.f, LFE_PLC_LPCORD + 1 - 2 ); -#else if ( epsP != NULL ) { epsP[0] = r[0]; epsP[1] = err; } -#endif for ( i = 2; i <= m; i++ ) { -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT s = 0.0; -#else - s = 0.0f; -#endif for ( j = 0; j < i; j++ ) { s += r[i - j] * a[j]; @@ -242,26 +210,10 @@ static int16_t lfeplc_lev_dur( rc[i - 1] = ( -s ) / err; -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( fabs( rc[i - 1] ) > 0.99945f ) -#else - if ( fabsf( rc[i - 1] ) > 0.99945f ) -#endif { flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT - } -#else - return flag; } - else - { - for ( j = 0; j <= m; j++ ) - { - a_out[j] = a[j]; - } - } -#endif for ( j = 1; j <= i / 2; j++ ) { @@ -279,13 +231,11 @@ static int16_t lfeplc_lev_dur( { err = 0.01f; } -#ifndef NONE_BE_FIX_816_LFE_PLC_FLOAT if ( epsP != NULL ) { epsP[i] = err; } -#endif } return ( flag ); @@ -320,11 +270,8 @@ static int16_t lfeplc_lev_dur( s = r[1]; a[1] = rc[0]; a_out[1] = a[1]; - err += rc[0] * s; - s += r[2] * a[1]; - rc[1] = ( -s ) / err; - i = 2; + i = 1; while ( i < m ) { for ( j = 1; j <= i / 2; j++ ) -- GitLab From d67e43c4f4f7867befd458e60fab1e1cbb8aa3fc Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Sun, 4 Aug 2024 20:34:36 +1000 Subject: [PATCH 23/24] clang format fix --- lib_dec/ivas_lfe_plc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 0c358f4233..05338b2c9c 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -261,7 +261,7 @@ static int16_t lfeplc_lev_dur( float s, at, err; float a[LFE_PLC_LPCORD + 1] = { 0.0f }; - set_f( a_out, 0.f, LFE_PLC_LPCORD + 1); + set_f( a_out, 0.f, LFE_PLC_LPCORD + 1 ); rc = &buf[0]; a[0] = 1.f; err = r[0]; -- GitLab From fc6bc79885418a18952570846c3e266328d17804 Mon Sep 17 00:00:00 2001 From: "Huo, Jiaquan" Date: Mon, 5 Aug 2024 10:33:54 +1000 Subject: [PATCH 24/24] no array init at declaration. --- lib_dec/ivas_lfe_plc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 05338b2c9c..99509970cb 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -259,8 +259,9 @@ static int16_t lfeplc_lev_dur( float buf[TCXLTP_LTP_ORDER]; float *rc; /* reflection coefficients 0,...,m-1 */ float s, at, err; - float a[LFE_PLC_LPCORD + 1] = { 0.0f }; + float a[LFE_PLC_LPCORD + 1]; + set_f( a, 0.f, LFE_PLC_LPCORD + 1 ); set_f( a_out, 0.f, LFE_PLC_LPCORD + 1 ); rc = &buf[0]; a[0] = 1.f; -- GitLab