Loading lib_dec/ivas_svd_dec_fx.c +26 −24 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ static void HouseholderReduction_fx( #ifdef MYCHANGES static void biDiagonalReductionLeft_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading @@ -78,7 +78,7 @@ static void biDiagonalReductionLeft_64( static void biDiagonalReductionRight_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 secDiag_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading Loading @@ -890,17 +890,19 @@ static void HouseholderReduction_fx( } for (nCh=0;nCh<nChannelsC;nCh++) { Word16 bitwindow; bitwindow=1; biDiagonalReductionLeft_64( singularVectors_Left_64,0, singularVectors_Left_64,bitwindow, singularValues_fx,singularValues_fx_e, nChannelsL, nChannelsC, nCh ); bitwindow=nCh+1; biDiagonalReductionRight_64( singularVectors_Left_64,nCh, singularVectors_Left_64,bitwindow, secDiag_fx,secDiag_fx_e, nChannelsL, nChannelsC, Loading Loading @@ -956,7 +958,7 @@ static void HouseholderReduction_fx( #ifdef MYCHANGES static void biDiagonalReductionLeft_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading @@ -968,7 +970,6 @@ static void biDiagonalReductionLeft_64( Word32 norm_x, g; Word16 norm_x_e, g_e; Word64 norm_64; Word16 bitwindow; norm_x=0; move32(); IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ Loading @@ -977,7 +978,6 @@ static void biDiagonalReductionLeft_64( Word32 tmp; norm_64=0; move64(); bitwindow=add(singularVectors_e,1); FOR( jCh = currChannel; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { tmp=W_extract_l(W_shr(singularVectors_Left_64[jCh][currChannel],bitwindow)); Loading @@ -985,7 +985,7 @@ static void biDiagonalReductionLeft_64( } n=W_norm(norm_64); norm_x=W_extract_h(W_shl(norm_64, n )); norm_x_e = add(sub(shl(singularVectors_e, 1), n), 3 ); norm_x_e = add(sub(shl(bitwindow, 1), n), 1 ); } IF ( norm_x ) { Loading @@ -1004,25 +1004,25 @@ static void biDiagonalReductionLeft_64( { g = L_negate( g ); } factor2 = W_extract_l( W_shr( singularVectors_Left_64[currChannel][currChannel], singularVectors_e) ); tmp_e=sub( sub( g_e, singularVectors_e), 2); factor2 = W_extract_l( W_shr( singularVectors_Left_64[currChannel][currChannel], bitwindow-1) ); tmp_e=sub( sub( g_e, bitwindow), 3); // bitwindow=singularvectors_e+1 --> g_e-sin_e-2 <=> g_e-bitwindow-3 tmpmul=W_mult0_32_32( g, factor2); tmpmul=W_shl(tmpmul, tmp_e); r_64=W_sub(tmpmul, norm_64); r_e=W_norm(r_64 ); r=W_extract_h( W_shl( r_64, r_e ) ); // r_e = sub( sub( add( add(1, singularVectors_e),g_e), tmp_e), r_e); // 1+singularVectors_e + g_e - ((g_e-singularVectors_e)-2)-r_e r_e = sub( add( 3, add(singularVectors_e, singularVectors_e )), r_e ); r_e = sub( add( 1, add(bitwindow, bitwindow )), r_e ); invVal_e = r_e; invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, r, &invVal_e); tmp_e = add(32, sub(singularVectors_e, g_e ) ); tmp_e = add(31, sub(bitwindow, g_e ) ); singularVectors_Left_64[currChannel][currChannel] = W_sub( singularVectors_Left_64[currChannel][currChannel], W_shr( W_deposit32_h( g), tmp_e) ); // here, the exponent goes up. bitwindow=add(singularVectors_e, 2); // so does the bit window bitwindow=add(bitwindow, 1); // so does the bit window FOR ( iCh = currChannel+1; iCh < nChannelsC; iCh++) { Word32 factor1; Loading @@ -1049,13 +1049,16 @@ static void biDiagonalReductionLeft_64( singularVectors_Left_64[jCh][iCh] = W_add( singularVectors_Left_64[jCh][iCh], W_shr(W_mult0_32_32( f, factor1 ), magic_shift ) ); } } singularValues[currChannel] = g; singularValues_e[currChannel] = g_e; move32(); move16(); } } static void biDiagonalReductionRight_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 secDiag_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading @@ -1072,8 +1075,8 @@ static void biDiagonalReductionRight_64( Word32 abs_x; Word16 abs_x_e; Word64 abs_64; Word16 bitwindow; Word16 idx; Word16 bitwindow0; Loading @@ -1081,6 +1084,7 @@ static void biDiagonalReductionRight_64( secDiag_e[currChannel] = ( *g_e ); move32(); move16(); bitwindow0=bitwindow; ( *g ) =0; ( *g_e ) = 0; Loading @@ -1089,10 +1093,8 @@ static void biDiagonalReductionRight_64( IF ( LT_16( currChannel, nChannelsL ) && NE_16( currChannel, sub( nChannelsC, 1 ) ) ) /* i <=m && i !=n */ { Word16 tmp_e; norm_64=0; move64(); bitwindow=add( singularVectors_e, 1); // FIXME: WHY NOT 2???? idx = add( currChannel, 1); FOR ( jCh = idx; jCh < nChannelsC; jCh++ ) { Loading @@ -1103,11 +1105,11 @@ static void biDiagonalReductionRight_64( } norm_x_e = W_norm( norm_64); norm_x = W_extract_h( W_shl( norm_64, norm_x_e) ); norm_x_e = add( sub( add( singularVectors_e, singularVectors_e), norm_x_e), 3); norm_x_e = add( sub( add( bitwindow, bitwindow), norm_x_e), 1); move16(); abs_x_e = W_norm( abs_64); abs_x = W_extract_h( W_shl( abs_64, abs_x_e) ); abs_x_e = add( sub( add( singularVectors_e, singularVectors_e), abs_x_e), 3); abs_x_e = add( sub( add( bitwindow, bitwindow), abs_x_e), 1); IF ( norm_x ) { Loading Loading @@ -1138,7 +1140,7 @@ static void biDiagonalReductionRight_64( move32(); move16(); factor2=W_extract_l( W_shr( singularVectors_Left_64[currChannel][idx], bitwindow) ); tmp_e = sub( sub( tmp_g_e, singularVectors_e), 1); tmp_e = sub( sub( tmp_g_e, bitwindow), 3); tmpmul = W_mult0_32_32( tmp_g, factor2); tmpmul = W_shl(tmpmul, tmp_e); Loading @@ -1154,10 +1156,9 @@ static void biDiagonalReductionRight_64( magic_shift=32-tmp_g_e; singularVectors_Left_64[currChannel][idx]=W_sub( singularVectors_Left_64[currChannel][idx], W_shr( W_deposit32_h( tmp_g), magic_shift) ); bitwindow=add(singularVectors_e,2); bitwindow=add(bitwindow, 1); FOR( iCh = idx; iCh < nChannelsC; iCh++ ) { Word16 magicshift; norm_64 = 0; move64(); Loading @@ -1184,7 +1185,8 @@ static void biDiagonalReductionRight_64( move16(); invVal = BASOP_Util_Divide3232_Scale_newton( abs_x, maxWithSign_fx( r ), &invVal_e); invVal_e = add( invVal_e, sub( abs_x_e, r_e) ); bitwindow = add(singularVectors_e, 1); bitwindow = bitwindow0; move16(); FOR ( jCh = idx; jCh < nChannelsL ; jCh++ ) { secDiag[jCh] = Mpy_32_32( W_extract_l( W_shr( singularVectors_Left_64[currChannel][jCh], bitwindow) ), invVal ); Loading Loading
lib_dec/ivas_svd_dec_fx.c +26 −24 Original line number Diff line number Diff line Loading @@ -68,7 +68,7 @@ static void HouseholderReduction_fx( #ifdef MYCHANGES static void biDiagonalReductionLeft_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading @@ -78,7 +78,7 @@ static void biDiagonalReductionLeft_64( static void biDiagonalReductionRight_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 secDiag_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading Loading @@ -890,17 +890,19 @@ static void HouseholderReduction_fx( } for (nCh=0;nCh<nChannelsC;nCh++) { Word16 bitwindow; bitwindow=1; biDiagonalReductionLeft_64( singularVectors_Left_64,0, singularVectors_Left_64,bitwindow, singularValues_fx,singularValues_fx_e, nChannelsL, nChannelsC, nCh ); bitwindow=nCh+1; biDiagonalReductionRight_64( singularVectors_Left_64,nCh, singularVectors_Left_64,bitwindow, secDiag_fx,secDiag_fx_e, nChannelsL, nChannelsC, Loading Loading @@ -956,7 +958,7 @@ static void HouseholderReduction_fx( #ifdef MYCHANGES static void biDiagonalReductionLeft_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 singularValues[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 singularValues_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading @@ -968,7 +970,6 @@ static void biDiagonalReductionLeft_64( Word32 norm_x, g; Word16 norm_x_e, g_e; Word64 norm_64; Word16 bitwindow; norm_x=0; move32(); IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ Loading @@ -977,7 +978,6 @@ static void biDiagonalReductionLeft_64( Word32 tmp; norm_64=0; move64(); bitwindow=add(singularVectors_e,1); FOR( jCh = currChannel; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { tmp=W_extract_l(W_shr(singularVectors_Left_64[jCh][currChannel],bitwindow)); Loading @@ -985,7 +985,7 @@ static void biDiagonalReductionLeft_64( } n=W_norm(norm_64); norm_x=W_extract_h(W_shl(norm_64, n )); norm_x_e = add(sub(shl(singularVectors_e, 1), n), 3 ); norm_x_e = add(sub(shl(bitwindow, 1), n), 1 ); } IF ( norm_x ) { Loading @@ -1004,25 +1004,25 @@ static void biDiagonalReductionLeft_64( { g = L_negate( g ); } factor2 = W_extract_l( W_shr( singularVectors_Left_64[currChannel][currChannel], singularVectors_e) ); tmp_e=sub( sub( g_e, singularVectors_e), 2); factor2 = W_extract_l( W_shr( singularVectors_Left_64[currChannel][currChannel], bitwindow-1) ); tmp_e=sub( sub( g_e, bitwindow), 3); // bitwindow=singularvectors_e+1 --> g_e-sin_e-2 <=> g_e-bitwindow-3 tmpmul=W_mult0_32_32( g, factor2); tmpmul=W_shl(tmpmul, tmp_e); r_64=W_sub(tmpmul, norm_64); r_e=W_norm(r_64 ); r=W_extract_h( W_shl( r_64, r_e ) ); // r_e = sub( sub( add( add(1, singularVectors_e),g_e), tmp_e), r_e); // 1+singularVectors_e + g_e - ((g_e-singularVectors_e)-2)-r_e r_e = sub( add( 3, add(singularVectors_e, singularVectors_e )), r_e ); r_e = sub( add( 1, add(bitwindow, bitwindow )), r_e ); invVal_e = r_e; invVal = BASOP_Util_Divide3232_Scale_newton( MAXVAL_WORD32, r, &invVal_e); tmp_e = add(32, sub(singularVectors_e, g_e ) ); tmp_e = add(31, sub(bitwindow, g_e ) ); singularVectors_Left_64[currChannel][currChannel] = W_sub( singularVectors_Left_64[currChannel][currChannel], W_shr( W_deposit32_h( g), tmp_e) ); // here, the exponent goes up. bitwindow=add(singularVectors_e, 2); // so does the bit window bitwindow=add(bitwindow, 1); // so does the bit window FOR ( iCh = currChannel+1; iCh < nChannelsC; iCh++) { Word32 factor1; Loading @@ -1049,13 +1049,16 @@ static void biDiagonalReductionLeft_64( singularVectors_Left_64[jCh][iCh] = W_add( singularVectors_Left_64[jCh][iCh], W_shr(W_mult0_32_32( f, factor1 ), magic_shift ) ); } } singularValues[currChannel] = g; singularValues_e[currChannel] = g_e; move32(); move16(); } } static void biDiagonalReductionRight_64( Word64 singularVectors_Left_64[MAX_OUTPUT_CHANNELS][MAX_OUTPUT_CHANNELS], Word16 singularVectors_e, Word16 bitwindow, Word32 secDiag[MAX_OUTPUT_CHANNELS], /* exp(singularValues_e) */ Word16 secDiag_e[MAX_OUTPUT_CHANNELS], const Word16 nChannelsL, /* Q0 */ Loading @@ -1072,8 +1075,8 @@ static void biDiagonalReductionRight_64( Word32 abs_x; Word16 abs_x_e; Word64 abs_64; Word16 bitwindow; Word16 idx; Word16 bitwindow0; Loading @@ -1081,6 +1084,7 @@ static void biDiagonalReductionRight_64( secDiag_e[currChannel] = ( *g_e ); move32(); move16(); bitwindow0=bitwindow; ( *g ) =0; ( *g_e ) = 0; Loading @@ -1089,10 +1093,8 @@ static void biDiagonalReductionRight_64( IF ( LT_16( currChannel, nChannelsL ) && NE_16( currChannel, sub( nChannelsC, 1 ) ) ) /* i <=m && i !=n */ { Word16 tmp_e; norm_64=0; move64(); bitwindow=add( singularVectors_e, 1); // FIXME: WHY NOT 2???? idx = add( currChannel, 1); FOR ( jCh = idx; jCh < nChannelsC; jCh++ ) { Loading @@ -1103,11 +1105,11 @@ static void biDiagonalReductionRight_64( } norm_x_e = W_norm( norm_64); norm_x = W_extract_h( W_shl( norm_64, norm_x_e) ); norm_x_e = add( sub( add( singularVectors_e, singularVectors_e), norm_x_e), 3); norm_x_e = add( sub( add( bitwindow, bitwindow), norm_x_e), 1); move16(); abs_x_e = W_norm( abs_64); abs_x = W_extract_h( W_shl( abs_64, abs_x_e) ); abs_x_e = add( sub( add( singularVectors_e, singularVectors_e), abs_x_e), 3); abs_x_e = add( sub( add( bitwindow, bitwindow), abs_x_e), 1); IF ( norm_x ) { Loading Loading @@ -1138,7 +1140,7 @@ static void biDiagonalReductionRight_64( move32(); move16(); factor2=W_extract_l( W_shr( singularVectors_Left_64[currChannel][idx], bitwindow) ); tmp_e = sub( sub( tmp_g_e, singularVectors_e), 1); tmp_e = sub( sub( tmp_g_e, bitwindow), 3); tmpmul = W_mult0_32_32( tmp_g, factor2); tmpmul = W_shl(tmpmul, tmp_e); Loading @@ -1154,10 +1156,9 @@ static void biDiagonalReductionRight_64( magic_shift=32-tmp_g_e; singularVectors_Left_64[currChannel][idx]=W_sub( singularVectors_Left_64[currChannel][idx], W_shr( W_deposit32_h( tmp_g), magic_shift) ); bitwindow=add(singularVectors_e,2); bitwindow=add(bitwindow, 1); FOR( iCh = idx; iCh < nChannelsC; iCh++ ) { Word16 magicshift; norm_64 = 0; move64(); Loading @@ -1184,7 +1185,8 @@ static void biDiagonalReductionRight_64( move16(); invVal = BASOP_Util_Divide3232_Scale_newton( abs_x, maxWithSign_fx( r ), &invVal_e); invVal_e = add( invVal_e, sub( abs_x_e, r_e) ); bitwindow = add(singularVectors_e, 1); bitwindow = bitwindow0; move16(); FOR ( jCh = idx; jCh < nChannelsL ; jCh++ ) { secDiag[jCh] = Mpy_32_32( W_extract_l( W_shr( singularVectors_Left_64[currChannel][jCh], bitwindow) ), invVal ); Loading