diff --git a/lib_com/hp50.c b/lib_com/hp50.c index 45b90f0cb95f27df640d762ac7fa7c977603d33d..0f950af36356a8fc07ad19729659fc8779f1247d 100644 --- a/lib_com/hp50.c +++ b/lib_com/hp50.c @@ -35,6 +35,7 @@ ====================================================================================*/ #include +#include #include "options.h" #include "prot.h" #include "wmc_auto.h" @@ -354,65 +355,224 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * move32(); mem[1] = L_shr(mem[1], diff); move32(); - mem[2] = L_shr(mem[2], diff); - move32(); - mem[3] = L_shr(mem[3], diff); - move32(); + mem[2] = L_shr( mem[2], diff ); + move32(); + mem[3] = L_shr( mem[3], diff ); + move32(); #endif - mem[4] = L_deposit_l(prescale); - } + mem[4] = L_deposit_l( prescale ); + } - IF(EQ_32(sFreq, 8000)) - { - /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate - [b,a] = butter(2, 20.0/4000.0, 'high'); - b = [0.988954248067140 -1.977908496134280 0.988954248067140] - a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/ - a1 = 1061816033l/* 1.977786483776764 Q29*/; move32(); - a2 = -525076131l/*-0.978030508491796 Q29*/; move32(); - b1 = -1061881538l/*-1.977908496134280 Q29*/; move32(); - b2 = 530940769l/* 0.988954248067140 Q29*/; move32(); + IF( EQ_32( sFreq, 8000 ) ) + { + /* hp filter 20Hz at 3dB for 8000 Hz input sampling rate + [b,a] = butter(2, 20.0/4000.0, 'high'); + b = [0.988954248067140 -1.977908496134280 0.988954248067140] + a = [1.000000000000000 -1.977786483776764 0.978030508491796]*/ + a1 = 1061816033l /* 1.977786483776764 Q29*/; + move32(); + a2 = -525076131l /*-0.978030508491796 Q29*/; + move32(); + b1 = -1061881538l /*-1.977908496134280 Q29*/; + move32(); + b2 = 530940769l /* 0.988954248067140 Q29*/; + move32(); + } + ELSE IF( EQ_32( sFreq, 16000 ) ) + { + /* hp filter 20Hz at 3dB for 16000KHz sampling rate + [b,a] = butter(2, 20.0/8000.0, 'high'); + b = [0.994461788958195 -1.988923577916390 0.994461788958195] + a = [1.000000000000000 -1.988892905899653 0.988954249933127] */ + a1 = 1067778748l /* 1.988892905899653 Q29*/; + move32(); + a2 = -530940770l /*-0.988954249933127 Q29*/; + move32(); + b1 = -1067795215l /*-1.988923577916390 Q29*/; + move32(); + b2 = 533897608l /* 0.994461788958195 Q29*/; + move32(); + } + ELSE IF( EQ_32( sFreq, 32000 ) ) + { + /* hp filter 20Hz at 3dB for 32000KHz sampling rate + [b,a] = butter(2, 20.0/16000.0, 'high'); + b = [0.997227049904470 -1.994454099808940 0.997227049904470] + a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/ + a1 = 1070760263l /* 1.994446410541927 Q29*/; + move32(); + a2 = -533897608l /*-0.994461789075954 Q29*/; + move32(); + b1 = -1070764392l /*-1.994454099808940 Q29*/; + move32(); + b2 = 535382196l /* 0.997227049904470 Q29*/; + move32(); + } + ELSE + { + assert( sFreq == 48000 ); + /* hp filter 20Hz at 3dB for 48000KHz sampling rate + [b,a] = butter(2, 20.0/24000.0, 'high'); + b =[0.998150511190452 -1.996301022380904 0.998150511190452] + a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ + a1 = 1071754114l /* 1.996297601769122 Q29*/; + move32(); + a2 = -534886875l /*-0.996304442992686 Q29*/; + move32(); + b1 = -1071755951l /*-1.996301022380904 Q29*/; + move32(); + b2 = 535877975l /* 0.998150511190452 Q29*/; + move32(); + } - } - ELSE IF(EQ_32(sFreq, 16000)) - { - /* hp filter 20Hz at 3dB for 16000KHz sampling rate - [b,a] = butter(2, 20.0/8000.0, 'high'); - b = [0.994461788958195 -1.988923577916390 0.994461788958195] - a = [1.000000000000000 -1.988892905899653 0.988954249933127] */ - a1 = 1067778748l/* 1.988892905899653 Q29*/; move32(); - a2 = -530940770l/*-0.988954249933127 Q29*/; move32(); - b1 = -1067795215l/*-1.988923577916390 Q29*/; move32(); - b2 = 533897608l/* 0.994461788958195 Q29*/; move32(); - } - ELSE IF(EQ_32(sFreq, 32000)) - { - /* hp filter 20Hz at 3dB for 32000KHz sampling rate - [b,a] = butter(2, 20.0/16000.0, 'high'); - b = [0.997227049904470 -1.994454099808940 0.997227049904470] - a = [1.000000000000000 -1.994446410541927 0.994461789075954]*/ - a1 = 1070760263l/* 1.994446410541927 Q29*/; move32(); - a2 = -533897608l/*-0.994461789075954 Q29*/; move32(); - b1 = -1070764392l/*-1.994454099808940 Q29*/; move32(); - b2 = 535382196l/* 0.997227049904470 Q29*/; move32(); - } - ELSE - { - assert(sFreq == 48000); - /* hp filter 20Hz at 3dB for 48000KHz sampling rate - [b,a] = butter(2, 20.0/24000.0, 'high'); - b =[0.998150511190452 -1.996301022380904 0.998150511190452] - a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ - a1 = 1071754114l/* 1.996297601769122 Q29*/; move32(); - a2 = -534886875l/*-0.996304442992686 Q29*/; move32(); - b1 = -1071755951l/*-1.996301022380904 Q29*/; move32(); - b2 = 535877975l/* 0.998150511190452 Q29*/; move32(); - } + filter_2nd_order( signal, stride, prescale, lg, + mem, a1, a2, b1, b2 ); + return; +} - filter_2nd_order(signal, stride, prescale, lg, - mem, a1, a2, b1, b2); - return; +void hp20_fix32( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs) +{ + Word16 i; + Word32 a1_fx, a2_fx, b1_fx, b2_fx; + Word16 Qx0, Qx1, Qx2, Qy1, Qprev_y1, Qy2, Qprev_y2, Qmin; + Word64 x0_fx64, x1_fx64, x2_fx64, y0_fx64, y1_fx64, y2_fx64, R1, R2, R3, R4, R5; + + if (Fs == 8000) + { + /* hp filter 20Hz at 3dB for 8000KHz input sampling rate + [b,a] = butter(2, 20.0/4000.0, 'high'); + b = [0.988954248067140 -1.977908496134280 0.988954248067140] + a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/ + a1_fx = 1061816033l /* 1.977786483776764 Q29*/; + a2_fx = -525076131l /*-0.978030508491796 Q29*/; + b1_fx = -1061881538l /*-1.977908496134280 Q29*/; + b2_fx = 530940769l /* 0.988954248067140 Q29*/; + } + else if (Fs == 16000) + { + /* hp filter 20Hz at 3dB for 16000KHz sampling rate + [b,a] = butter(2, 20.0/8000.0, 'high'); + b =[ 0.994461788958195 -1.988923577916390 0.994461788958195] + a =[1.000000000000000 -1.988892905899653 0.988954249933127] */ + a1_fx = 1067778748l /* 1.988892905899653 Q29*/; + a2_fx = -530940770l /*-0.988954249933127 Q29*/; + b1_fx = -1067795215l /*-1.988923577916390 Q29*/; + b2_fx = 533897608l /* 0.994461788958195 Q29*/; + } + else if (Fs == 32000) + { + /* hp filter 20Hz at 3dB for 32000KHz sampling rate + [b,a] = butter(2, 20.0/16000.0, 'high'); + b =[0.997227049904470 -1.994454099808940 0.997227049904470] + a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/ + a1_fx = 1070760263l /* 1.994446410541927 Q29*/; + a2_fx = -533897608l /*-0.994461789075954 Q29*/; + b1_fx = -1070764392l /*-1.994454099808940 Q29*/; + b2_fx = 535382196l /* 0.997227049904470 Q29*/; + } + else + { + /* hp filter 20Hz at 3dB for 48000KHz sampling rate + [b,a] = butter(2, 20.0/24000.0, 'high'); + b =[ 0.998150511190452 -1.996301022380904 0.998150511190452] + a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/ + a1_fx = 1071754114l /* 1.996297601769122 Q29*/; + a2_fx = -534886875l /*-0.996304442992686 Q29*/; + b1_fx = -1071755951l /*-1.996301022380904 Q29*/; + b2_fx = 535877975l /* 0.998150511190452 Q29*/; + } + + Qprev_y1 = mem_fx[4]; + Qprev_y2 = mem_fx[5]; + y1_fx64 = mem_fx[0]; + y2_fx64 = mem_fx[1]; + x0_fx64 = mem_fx[2]; + x1_fx64 = mem_fx[3]; + + for (i = 0; i < lg; i++) + { + x2_fx64 = x1_fx64; + x1_fx64 = x0_fx64; + x0_fx64 = signal_fx[i]; + + Qy1 = W_norm(y1_fx64); + if (y1_fx64 == 0) { + Qy1 = 62; + } + Qy1 = Qy1 - 34; + R1 = W_shl(y1_fx64, Qy1) * a1_fx; + Qy1 += Qprev_y1; + + Qy2 = W_norm(y2_fx64); + if (y2_fx64 == 0) { + Qy2 = 62; + } + Qy2 = Qy2 - 34; + R2 = W_shl(y2_fx64, Qy2) * a2_fx; + Qy2 += Qprev_y2; + + Qx0 = W_norm(x0_fx64); + if (x0_fx64 == 0) { + Qx0 = 62; + } + Qx0 = Qx0 - 34; + R3 = W_shl(x0_fx64, Qx0) * b2_fx; + + Qx1 = W_norm(x1_fx64); + if (x1_fx64 == 0) { + Qx1 = 62; + } + Qx1 = Qx1 - 34; + R4 = W_shl(x1_fx64, Qx1) * b1_fx; + + Qx2 = W_norm(x2_fx64); + if (x2_fx64 == 0) { + Qx2 = 62; + } + Qx2 = Qx2 - 34; + R5 = W_shl(x2_fx64, Qx2) * b2_fx; + + Qmin = min(Qy1, Qy2); + y0_fx64 = (R1 >> (Qy1 - Qmin)) + (R2 >> (Qy2 - Qmin)); + Qmin = min(Qmin, Qx0); + Qmin = min(Qmin, Qx1); + Qmin = min(Qmin, Qx2); + y0_fx64 = (y0_fx64 >> (min(Qy1, Qy2) - Qmin)) + (R3 >> (Qx0 - Qmin)) + (R4 >> (Qx1 - Qmin)) + (R5 >> (Qx2 - Qmin)); + y0_fx64 = y0_fx64 >> 29; + + signal_fx[i] = W_shr(y0_fx64, Qmin); + + y2_fx64 = y1_fx64; + y1_fx64 = y0_fx64; + Qprev_y2 = Qprev_y1; + Qprev_y1 = Qmin; + } + + Qy1 = W_norm(y1_fx64); + if (y1_fx64 != 0 && Qy1 < 32) { + y1_fx64 = y1_fx64 >> (32 - Qy1); + Qprev_y1 -= (32 - Qy1); + } + + Qy2 = W_norm(y2_fx64); + if (y2_fx64 != 0 && Qy2 < 32) { + y2_fx64 = y2_fx64 >> (32 - Qy2); + Qprev_y2 -= (32 - Qy2); + } + + mem_fx[0] = y1_fx64; + mem_fx[1] = y2_fx64; + mem_fx[2] = x0_fx64; + mem_fx[3] = x1_fx64; + mem_fx[4] = Qprev_y1; + mem_fx[5] = Qprev_y2; + + return; } diff --git a/lib_com/prot.h b/lib_com/prot.h index 6a0639df9b61b653f8a9b8557966d69daf528c27..7b534da85fb1ffd0a4e82ac36eca77c096b2c950 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -6746,6 +6746,14 @@ void hp20_flt( Float32 mem[], const Word32 Fs ); +#ifdef IVAS_FLOAT_FIXED +void hp20_fix32( + Word32 signal_fx[], + const Word16 lg, + Word32 mem_fx[], + const Word32 Fs); +#endif // IVAS_FLOAT_FIXED + void ham_cos_window_flt( float *fh, const int16_t n1, diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index 8de531e5b775f0db87d831cd1cbe3c9e54fc018e..b64288fb8eaf5ef6fdf1b4f921f4a6a809c14493 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -437,12 +437,12 @@ ivas_error ivas_hp20_dec_reconfig_fx( /* create additional hp20 memories */ FOR ( ; i < nchan_hp20; i++ ) { - IF ( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( L_HP20_MEM * sizeof( Word32 ) ) ) == NULL ) + IF ( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( (L_HP20_MEM + 2) * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } - set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM ); + set32_fx( st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2); } free( old_mem_hp20_out_fx ); diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 31b245c6d1e2bc8db115be445cc8f4068accf1e2..ef6569cde2ec124e7aad2e84b81512d66560b4a8 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1706,6 +1706,9 @@ ivas_error ivas_init_decoder( ELSE { st_ivas->mem_hp20_out = NULL; +#ifdef IVAS_FLOAT_FIXED + st_ivas->mem_hp20_out_fx = NULL; +#endif // IVAS_FLOAT_FIXED } FOR ( i = 0; i < n; i++ ) @@ -1715,13 +1718,16 @@ ivas_error ivas_init_decoder( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); } + set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM ); #ifdef IVAS_FLOAT_FIXED - IF( ( st_ivas->mem_hp20_out_fx[i] = (Word32 *) malloc( L_HP20_MEM * sizeof(Word32) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); - } + + IF((st_ivas->mem_hp20_out_fx[i] = (Word32 *)malloc((L_HP20_MEM + 2) * sizeof(Word32))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n")); + } + + set32_fx(st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2); #endif // IVAS_FLOAT_FIXED - set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM ); } /*-------------------------------------------------------------------* @@ -2403,7 +2409,18 @@ void ivas_destroy_dec( free( st_ivas->mem_hp20_out ); st_ivas->mem_hp20_out = NULL; } - +#ifdef IVAS_FLOAT_FIXED + IF( st_ivas->mem_hp20_out_fx != NULL ) + { + FOR( i = 0; i < getNumChanSynthesis( st_ivas ); i++ ) + { + free( st_ivas->mem_hp20_out_fx[i] ); + st_ivas->mem_hp20_out_fx[i] = NULL; + } + free( st_ivas->mem_hp20_out_fx ); + st_ivas->mem_hp20_out_fx = NULL; + } +#endif /* ISM metadata handles */ ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 8b972783fc29a16b502590272408e6d7250b308c..1a9ced0353dcbcaeb79eee13747cb2b24d8534c6 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -199,7 +199,20 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < min( nchan_out, st_ivas->nchan_transport ); n++ ) { +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float)p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); +#endif // IVAS_FLOAT_FIXED } if ( st_ivas->renderer_type == RENDERER_MC && st_ivas->hDecoderConfig->nchan_out == 1 ) @@ -207,7 +220,7 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED Word16 i, j, q = Q16; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); @@ -219,8 +232,8 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); } } - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) + ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); free( p_output_fx[i] ); @@ -437,7 +450,20 @@ ivas_error ivas_jbm_dec_tc( } /* HP filtering */ +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); +#endif // IVAS_FLOAT_FIXED } if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -591,9 +617,9 @@ ivas_error ivas_jbm_dec_tc( { FOR( Word16 block = 0; block < MAX_PARAM_SPATIAL_SUBFRAMES; block++ ) { - FOR(Word16 b = 0; b < st_ivas->hSpatParamRendCom->num_freq_bands; b++) + FOR( Word16 b = 0; b < st_ivas->hSpatParamRendCom->num_freq_bands; b++ ) { - st_ivas->hMasaIsmData->energy_ratio_ism[i][block][b] = fix_to_float(st_ivas->hMasaIsmData->energy_ratio_ism_fx[i][block][b], Q30); + st_ivas->hMasaIsmData->energy_ratio_ism[i][block][b] = fix_to_float( st_ivas->hMasaIsmData->energy_ratio_ism_fx[i][block][b], Q30 ); } } } @@ -924,7 +950,20 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < nchan_remapped; n++ ) { +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); +#endif // IVAS_FLOAT_FIXED } if ( st_ivas->ivas_format == SBA_FORMAT ) @@ -1029,7 +1068,7 @@ ivas_error ivas_jbm_dec_tc( /* MASA metadata decoding */ #ifdef IVAS_FLOAT_FIXED - IF ( ( error = ivas_masa_decode( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_masa_decode( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) #else if ( ( error = ivas_masa_decode( st_ivas, st_ivas->hCPE[0]->hCoreCoder[0], &nb_bits_metadata[0] ) ) != IVAS_ERR_OK ) #endif @@ -1118,7 +1157,20 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); +#endif // IVAS_FLOAT_FIXED } if ( st_ivas->renderer_type == RENDERER_MONO_DOWNMIX ) @@ -1326,7 +1378,20 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { - hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for (int i = 0; i < output_frame; i++) + { + p_output_fix[i] = (Word32)(p_output[n][i] * (1 << 11)); + } + hp20_fix32(p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs); + for (int i = 0; i < output_frame; i++) + { + p_output[n][i] = (float)p_output_fix[i] / (1 << 11); + } +#else + hp20_flt(p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs); +#endif // IVAS_FLOAT_FIXED } #ifdef IVAS_FLOAT_FIXED @@ -1587,8 +1652,21 @@ ivas_error ivas_jbm_dec_tc( { if ( n != LFE_CHANNEL ) { +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); - } +#endif // IVAS_FLOAT_FIXED + } } if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) ) @@ -1642,7 +1720,7 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED Word16 i, j, q = Q16; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); @@ -1655,7 +1733,7 @@ ivas_error ivas_jbm_dec_tc( } } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); free( p_output_fx[i] ); @@ -1701,8 +1779,21 @@ ivas_error ivas_jbm_dec_tc( { if ( n != LFE_CHANNEL ) { +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); - } +#endif // IVAS_FLOAT_FIXED + } } /* Rendering */ @@ -1720,7 +1811,7 @@ ivas_error ivas_jbm_dec_tc( Word16 i, j, q = Q16, nchan_transport; nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); q = q - find_guarded_bits_fx( nchan_transport ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, nchan_transport); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); @@ -1733,7 +1824,7 @@ ivas_error ivas_jbm_dec_tc( } } ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, nchan_transport); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); free( p_output_fx[i] ); @@ -1790,8 +1881,21 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < st_ivas->nchan_transport; n++ ) { +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); - } +#endif // IVAS_FLOAT_FIXED + } /* Rendering */ if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) @@ -1799,7 +1903,7 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED Word16 i, j, q = Q16; q = q - find_guarded_bits_fx( st_ivas->nchan_transport ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, output_frame ); @@ -1812,7 +1916,7 @@ ivas_error ivas_jbm_dec_tc( } } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport); ++i) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], q, output_frame ); free( p_output_fx[i] ); @@ -2094,8 +2198,21 @@ ivas_error ivas_jbm_dec_tc( /* HP filtering */ for ( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) { +#ifdef IVAS_FLOAT_FIXED + Word32 p_output_fix[L_FRAME48k]; + for ( int i = 0; i < output_frame; i++ ) + { + p_output_fix[i] = (Word32) ( p_output[n][i] * ( 1 << 11 ) ); + } + hp20_fix32( p_output_fix, output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + for ( int i = 0; i < output_frame; i++ ) + { + p_output[n][i] = (float) p_output_fix[i] / ( 1 << 11 ); + } +#else hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); - } +#endif // IVAS_FLOAT_FIXED + } if ( st_ivas->renderer_type == RENDERER_MCMASA_MONO_STEREO ) { @@ -3139,7 +3256,7 @@ ivas_error ivas_jbm_dec_render( #ifdef IVAS_FLOAT_FIXED Word16 q = Q16; q = q - find_guarded_bits_fx( MC_PARAMUPMIX_MAX_INPUT_CHANS ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { p_output_fx[i] = malloc( L_FRAME48k * sizeof( Word32 ) ); floatToFixed_arrL( p_output[i], p_output_fx[i], q, *nSamplesRendered ); @@ -3152,9 +3269,9 @@ ivas_error ivas_jbm_dec_render( } } ivas_ls_setup_conversion_fx( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output_fx, p_output_fx ); - FOR( i = 0; i < max(st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS); ++i ) + FOR( i = 0; i < max( st_ivas->hDecoderConfig->nchan_out, MC_PARAMUPMIX_MAX_INPUT_CHANS ); ++i ) { - fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered); + fixedToFloat_arrL( p_output_fx[i], p_output[i], q, *nSamplesRendered ); free( p_output_fx[i] ); } #else diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 0f8eb79b52fcd249b8c2c9672812d6214c86874b..7b6a8b6bdc8e77569ba1458ec38f42992fbfb6fa 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1381,6 +1381,12 @@ static ivas_error ivas_mc_dec_reconfig( /*-----------------------------------------------------------------* * re-configure HP20 memories *-----------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED + if ( (error = ivas_hp20_dec_reconfig_fx(st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK) + { + return error; + } +#endif // IVAS_FLOAT_FIXED if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) { diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 6c532053636cbd406a40160ad53d2ef09d4da48b..9dc355a7d28e3afac98d1ac989a91a04ee50d6cb 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -370,6 +370,12 @@ ivas_error ivas_omasa_dec_config( ivas_set_omasa_TC( st_ivas->ism_mode, st_ivas->nchan_ism, &st_ivas->nSCE, &st_ivas->nCPE ); /* re-configure hp20 memories */ +#ifdef IVAS_FLOAT_FIXED + if ((error = ivas_hp20_dec_reconfig_fx(st_ivas, nchan_hp20_old)) != IVAS_ERR_OK) + { + return error; + } +#endif // IVAS_FLOAT_FIXED if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 4af1b1bd2ca8bdb2acc03540bda2b1682b866acb..324143705c72482cd69f97f4fff607aedadddc1f 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -598,7 +598,12 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * HP20 memories *-----------------------------------------------------------------*/ - +#ifdef IVAS_FLOAT_FIXED + if ((error = ivas_hp20_dec_reconfig_fx(st_ivas, nchan_hp20_old)) != IVAS_ERR_OK) + { + return error; + } +#endif // IVAS_FLOAT_FIXED if ( ( error = ivas_hp20_dec_reconfig( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) { return error;