Loading lib_com/hp50.c +214 −54 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ ====================================================================================*/ #include <stdint.h> #include <math.h> #include "options.h" #include "prot.h" #include "wmc_auto.h" Loading Loading @@ -368,11 +369,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); 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 ) ) { Loading @@ -380,11 +384,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); 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 ) ) { Loading @@ -392,10 +399,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); 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 { Loading @@ -404,10 +415,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); a1 = 1071754114l /* 1.996297601769122 Q29*/; move32(); a2 = -534886875l /*-0.996304442992686 Q29*/; move32(); b1 = -1071755951l /*-1.996301022380904 Q29*/; move32(); b2 = 535877975l /* 0.998150511190452 Q29*/; move32(); } Loading @@ -416,3 +431,148 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * 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; } lib_com/prot.h +8 −0 Original line number Diff line number Diff line Loading @@ -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, Loading lib_dec/ivas_corecoder_dec_reconfig.c +2 −2 Original line number Diff line number Diff line Loading @@ -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 ); Loading lib_dec/ivas_init_dec.c +23 −6 Original line number Diff line number Diff line Loading @@ -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++ ) Loading @@ -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 ) 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 ); } /*-------------------------------------------------------------------* Loading Loading @@ -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 ); Loading lib_dec/ivas_jbm_dec.c +137 −20 Original line number Diff line number Diff line Loading @@ -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 ) Loading Loading @@ -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 ) Loading Loading @@ -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 ) Loading Loading @@ -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 ) Loading Loading @@ -1326,7 +1378,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 } #ifdef IVAS_FLOAT_FIXED Loading Loading @@ -1587,7 +1652,20 @@ 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 } } Loading Loading @@ -1701,7 +1779,20 @@ 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 } } Loading Loading @@ -1790,7 +1881,20 @@ 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 */ Loading Loading @@ -2094,7 +2198,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_MCMASA_MONO_STEREO ) Loading Loading
lib_com/hp50.c +214 −54 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ ====================================================================================*/ #include <stdint.h> #include <math.h> #include "options.h" #include "prot.h" #include "wmc_auto.h" Loading Loading @@ -368,11 +369,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); 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 ) ) { Loading @@ -380,11 +384,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); 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 ) ) { Loading @@ -392,10 +399,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); 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 { Loading @@ -404,10 +415,14 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * [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(); a1 = 1071754114l /* 1.996297601769122 Q29*/; move32(); a2 = -534886875l /*-0.996304442992686 Q29*/; move32(); b1 = -1071755951l /*-1.996301022380904 Q29*/; move32(); b2 = 535877975l /* 0.998150511190452 Q29*/; move32(); } Loading @@ -416,3 +431,148 @@ void hp20(Word16 signal[], /* i/o: signal to filter any * 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; }
lib_com/prot.h +8 −0 Original line number Diff line number Diff line Loading @@ -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, Loading
lib_dec/ivas_corecoder_dec_reconfig.c +2 −2 Original line number Diff line number Diff line Loading @@ -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 ); Loading
lib_dec/ivas_init_dec.c +23 −6 Original line number Diff line number Diff line Loading @@ -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++ ) Loading @@ -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 ) 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 ); } /*-------------------------------------------------------------------* Loading Loading @@ -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 ); Loading
lib_dec/ivas_jbm_dec.c +137 −20 Original line number Diff line number Diff line Loading @@ -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 ) Loading Loading @@ -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 ) Loading Loading @@ -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 ) Loading Loading @@ -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 ) Loading Loading @@ -1326,7 +1378,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 } #ifdef IVAS_FLOAT_FIXED Loading Loading @@ -1587,7 +1652,20 @@ 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 } } Loading Loading @@ -1701,7 +1779,20 @@ 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 } } Loading Loading @@ -1790,7 +1881,20 @@ 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 */ Loading Loading @@ -2094,7 +2198,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_MCMASA_MONO_STEREO ) Loading