Loading lib_dec/ivas_svd_dec.c +5 −105 Original line number Diff line number Diff line Loading @@ -66,8 +66,6 @@ #if 1 #define OPT_DIV #define OPT_DIV_NORM /* 5 dB SNR precision improvement */ #define OPT_SUM /* Very little WMOPS savings */ #define OPT_SUM2 /* Very little WMOPS savings */ #define OPT_GIVENS #define OPT_GIVENS_INV Loading Loading @@ -1406,67 +1404,6 @@ Word32 BASOP_Util_Inv32(Word32 x, Word16 *px_e) } #endif #ifdef OPT_SUM static Word32 BASOP_Util_Accu_Mant32Exp /* o : normalized result mantissa */ ( Word32 a_m, /* i : Mantissa of 1st operand a */ Word16 *p_a_e, /* i/o : Exponent of 1st operand a */ Word32 b_m, /* i : Mantissa of 2nd operand b */ Word16 b_e /* i : Exponent of 2nd operand b */ ) { Word32 L_tmp; Word16 shift, a_e = *p_a_e; /* Compare exponents: the difference is limited to +/- 30 The Word32 mantissa of the operand with lower exponent is shifted right by the exponent difference. Then, the unshifted mantissa of the operand with the higher exponent is added. The addition result is normalized and the result represents the mantissa to return. The returned exponent takes into account all shift operations. */ #if 0 if ( !a_m ) a_e = add( b_e, 0 ); #endif if ( !b_m ) b_e = add( a_e, 0 ); shift = sub( a_e, b_e ); #if 0 shift = s_max( -31, shift ); shift = s_min( 31, shift ); #endif if ( shift < 0 ) { /* exponent of b is greater than exponent of a, shr a_m */ a_m = L_shl( a_m, shift ); } if ( shift > 0 ) { /* exponent of a is greater than exponent of b */ b_m = L_shr( b_m, shift ); } a_e = add( s_max( a_e, b_e ), 1 ); L_tmp = L_add( L_shr( a_m, 1 ), L_shr( b_m, 1 ) ); #if 1 shift = norm_l( L_tmp ); if ( shift ) L_tmp = L_shl( L_tmp, shift ); #if 0 if ( L_tmp == 0 ) a_e = add( 0, 0 ); #endif if ( L_tmp != 0 ) a_e = sub( a_e, shift ); #endif *p_a_e = a_e; return ( L_tmp ); } #endif #ifdef IVAS_FLOAT_FIXED static void biDiagonalReductionLeft_fx( Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ Loading Loading @@ -1523,21 +1460,12 @@ move32(); IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ { #ifdef OPT_SUM2 *sig_x_e = -31; move16(); #endif idx = currChannel; move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { #ifdef OPT_SUM2 ( *sig_x ) = BASOP_Util_Accu_Mant32Exp( *sig_x, sig_x_e, L_abs( singularVectors[jCh][currChannel] ), *singularVectors_e ); /* exp(sig_x_e) */ #else ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[jCh][currChannel] ), *singularVectors_e, sig_x_e ); /* exp(sig_x_e) */ #endif } IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ Loading @@ -1553,11 +1481,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ #endif norm_x = 0; move32(); #ifdef OPT_SUM2 norm_x_e = -31; #else norm_x_e = 0; #endif move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { Loading @@ -1578,11 +1502,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ move32(); sing_exp[jCh] = add( sing_exp[jCh], sub( *singularVectors_e, *sig_x_e ) ); move16(); #ifdef OPT_SUM2 norm_x = BASOP_Util_Accu_Mant32Exp( norm_x, &norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ) ); /* exp(norm_x_e) */ #else norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ #endif } IF( GT_16( norm_x_e, 0 ) ) { Loading Loading @@ -1628,19 +1548,11 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ { norm_x = 0; move32(); #ifdef OPT_SUM2 norm_x_e = -31; #else norm_x_e = 0; #endif move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { #ifdef OPT_SUM2 norm_x = BASOP_Util_Accu_Mant32Exp( norm_x, &norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( sing_exp[jCh], *singularVectors_e )); /* exp(norm_x_e) */ #else norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( sing_exp[jCh], *singularVectors_e ), &norm_x_e ); /* exp(norm_x_e) */ #endif } #ifndef OPT_DIV Loading Loading @@ -1821,18 +1733,9 @@ static void biDiagonalReductionRight_fx( { idx = add( currChannel, 1 ); /* Q0 */ #ifdef OPT_SUM *sig_x_e = -31; move16(); #endif FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { #ifdef OPT_SUM ( *sig_x ) = BASOP_Util_Accu_Mant32Exp( *sig_x, sig_x_e, L_abs( singularVectors[currChannel][jCh] ), *singularVectors_e ); /* exp(sig_x_e) */ #else ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[currChannel][jCh] ), *singularVectors_e, sig_x_e ); /* exp(sig_x_e) */ #endif } IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ Loading Loading @@ -1932,19 +1835,11 @@ static void biDiagonalReductionRight_fx( { norm_x = 0; move32(); #ifdef OPT_SUM2 norm_x_e = -31; #else norm_x_e = 0; #endif move16(); FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { #ifdef OPT_SUM2 norm_x = BASOP_Util_Accu_Mant32Exp( norm_x, &norm_x_e, Mpy_32_32( singularVectors[iCh][jCh], singularVectors[currChannel][jCh] ), add( *singularVectors_e, sing_exp[jCh] ) ); /* exp(sig_x_e) */ #else norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[iCh][jCh], singularVectors[currChannel][jCh] ), add( *singularVectors_e, sing_exp[jCh] ), &norm_x_e ); /* exp(norm_x_e) */ #endif } FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ Loading Loading @@ -2280,8 +2175,13 @@ static void singularVectorsAccumulationRight_fx( FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC*/ { #ifdef OPT_DIVno ratio_float = BASOP_Util_Divide3232_Scale( singularVectors_Left[nCh][iCh], maxWithSign_fx( singularVectors_Left[nCh][nCh + 1] ), &temp_exp1 ); /* exp(temp_exp1) */ singularVectors_Right[iCh][nCh] = BASOP_Util_Divide3232_Scale( ratio_float, maxWithSign_fx( t_ii ), &sing_right_exp[iCh][nCh] ); /* exp(sing_right_exp + (temp_exp1 - secDiag_e) */ #else ratio_float = BASOP_Util_Divide3232_Scale_cadence( singularVectors_Left[nCh][iCh], maxWithSign_fx( singularVectors_Left[nCh][nCh + 1] ), &temp_exp1 ); /* exp(temp_exp1) */ singularVectors_Right[iCh][nCh] = BASOP_Util_Divide3232_Scale_cadence( ratio_float, maxWithSign_fx( t_ii ), &sing_right_exp[iCh][nCh] ); /* exp(sing_right_exp + (temp_exp1 - secDiag_e) */ #endif move32(); sing_right_exp[iCh][nCh] = add( sing_right_exp[iCh][nCh], sub( temp_exp1, secDiag_e ) ); move16(); Loading Loading
lib_dec/ivas_svd_dec.c +5 −105 Original line number Diff line number Diff line Loading @@ -66,8 +66,6 @@ #if 1 #define OPT_DIV #define OPT_DIV_NORM /* 5 dB SNR precision improvement */ #define OPT_SUM /* Very little WMOPS savings */ #define OPT_SUM2 /* Very little WMOPS savings */ #define OPT_GIVENS #define OPT_GIVENS_INV Loading Loading @@ -1406,67 +1404,6 @@ Word32 BASOP_Util_Inv32(Word32 x, Word16 *px_e) } #endif #ifdef OPT_SUM static Word32 BASOP_Util_Accu_Mant32Exp /* o : normalized result mantissa */ ( Word32 a_m, /* i : Mantissa of 1st operand a */ Word16 *p_a_e, /* i/o : Exponent of 1st operand a */ Word32 b_m, /* i : Mantissa of 2nd operand b */ Word16 b_e /* i : Exponent of 2nd operand b */ ) { Word32 L_tmp; Word16 shift, a_e = *p_a_e; /* Compare exponents: the difference is limited to +/- 30 The Word32 mantissa of the operand with lower exponent is shifted right by the exponent difference. Then, the unshifted mantissa of the operand with the higher exponent is added. The addition result is normalized and the result represents the mantissa to return. The returned exponent takes into account all shift operations. */ #if 0 if ( !a_m ) a_e = add( b_e, 0 ); #endif if ( !b_m ) b_e = add( a_e, 0 ); shift = sub( a_e, b_e ); #if 0 shift = s_max( -31, shift ); shift = s_min( 31, shift ); #endif if ( shift < 0 ) { /* exponent of b is greater than exponent of a, shr a_m */ a_m = L_shl( a_m, shift ); } if ( shift > 0 ) { /* exponent of a is greater than exponent of b */ b_m = L_shr( b_m, shift ); } a_e = add( s_max( a_e, b_e ), 1 ); L_tmp = L_add( L_shr( a_m, 1 ), L_shr( b_m, 1 ) ); #if 1 shift = norm_l( L_tmp ); if ( shift ) L_tmp = L_shl( L_tmp, shift ); #if 0 if ( L_tmp == 0 ) a_e = add( 0, 0 ); #endif if ( L_tmp != 0 ) a_e = sub( a_e, shift ); #endif *p_a_e = a_e; return ( L_tmp ); } #endif #ifdef IVAS_FLOAT_FIXED static void biDiagonalReductionLeft_fx( Word32 singularVectors[][MAX_OUTPUT_CHANNELS], /* exp(singularVectors_e) */ Loading Loading @@ -1523,21 +1460,12 @@ move32(); IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ { #ifdef OPT_SUM2 *sig_x_e = -31; move16(); #endif idx = currChannel; move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { #ifdef OPT_SUM2 ( *sig_x ) = BASOP_Util_Accu_Mant32Exp( *sig_x, sig_x_e, L_abs( singularVectors[jCh][currChannel] ), *singularVectors_e ); /* exp(sig_x_e) */ #else ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[jCh][currChannel] ), *singularVectors_e, sig_x_e ); /* exp(sig_x_e) */ #endif } IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ Loading @@ -1553,11 +1481,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ #endif norm_x = 0; move32(); #ifdef OPT_SUM2 norm_x_e = -31; #else norm_x_e = 0; #endif move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { Loading @@ -1578,11 +1502,7 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ move32(); sing_exp[jCh] = add( sing_exp[jCh], sub( *singularVectors_e, *sig_x_e ) ); move16(); #ifdef OPT_SUM2 norm_x = BASOP_Util_Accu_Mant32Exp( norm_x, &norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ) ); /* exp(norm_x_e) */ #else norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][currChannel] ), shl( sing_exp[jCh], 1 ), &norm_x_e ); /* exp(norm_x_e) */ #endif } IF( GT_16( norm_x_e, 0 ) ) { Loading Loading @@ -1628,19 +1548,11 @@ IF( LT_16( currChannel, nChannelsL ) ) /* i <= m */ { norm_x = 0; move32(); #ifdef OPT_SUM2 norm_x_e = -31; #else norm_x_e = 0; #endif move16(); FOR( jCh = idx; jCh < nChannelsL; jCh++ ) /* nChannelsL */ { #ifdef OPT_SUM2 norm_x = BASOP_Util_Accu_Mant32Exp( norm_x, &norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( sing_exp[jCh], *singularVectors_e )); /* exp(norm_x_e) */ #else norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[jCh][currChannel], singularVectors[jCh][iCh] ), add( sing_exp[jCh], *singularVectors_e ), &norm_x_e ); /* exp(norm_x_e) */ #endif } #ifndef OPT_DIV Loading Loading @@ -1821,18 +1733,9 @@ static void biDiagonalReductionRight_fx( { idx = add( currChannel, 1 ); /* Q0 */ #ifdef OPT_SUM *sig_x_e = -31; move16(); #endif FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { #ifdef OPT_SUM ( *sig_x ) = BASOP_Util_Accu_Mant32Exp( *sig_x, sig_x_e, L_abs( singularVectors[currChannel][jCh] ), *singularVectors_e ); /* exp(sig_x_e) */ #else ( *sig_x ) = BASOP_Util_Add_Mant32Exp( *sig_x, *sig_x_e, L_abs( singularVectors[currChannel][jCh] ), *singularVectors_e, sig_x_e ); /* exp(sig_x_e) */ #endif } IF( ( *sig_x ) ) /*(fabsf(*sig_x) > EPSILON * fabsf(*sig_x)) { */ Loading Loading @@ -1932,19 +1835,11 @@ static void biDiagonalReductionRight_fx( { norm_x = 0; move32(); #ifdef OPT_SUM2 norm_x_e = -31; #else norm_x_e = 0; #endif move16(); FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ { #ifdef OPT_SUM2 norm_x = BASOP_Util_Accu_Mant32Exp( norm_x, &norm_x_e, Mpy_32_32( singularVectors[iCh][jCh], singularVectors[currChannel][jCh] ), add( *singularVectors_e, sing_exp[jCh] ) ); /* exp(sig_x_e) */ #else norm_x = BASOP_Util_Add_Mant32Exp( norm_x, norm_x_e, Mpy_32_32( singularVectors[iCh][jCh], singularVectors[currChannel][jCh] ), add( *singularVectors_e, sing_exp[jCh] ), &norm_x_e ); /* exp(norm_x_e) */ #endif } FOR( jCh = idx; jCh < nChannelsC; jCh++ ) /* nChannelsC */ Loading Loading @@ -2280,8 +2175,13 @@ static void singularVectorsAccumulationRight_fx( FOR( iCh = nCh + 1; iCh < nChannelsC; iCh++ ) /* nChannelsC*/ { #ifdef OPT_DIVno ratio_float = BASOP_Util_Divide3232_Scale( singularVectors_Left[nCh][iCh], maxWithSign_fx( singularVectors_Left[nCh][nCh + 1] ), &temp_exp1 ); /* exp(temp_exp1) */ singularVectors_Right[iCh][nCh] = BASOP_Util_Divide3232_Scale( ratio_float, maxWithSign_fx( t_ii ), &sing_right_exp[iCh][nCh] ); /* exp(sing_right_exp + (temp_exp1 - secDiag_e) */ #else ratio_float = BASOP_Util_Divide3232_Scale_cadence( singularVectors_Left[nCh][iCh], maxWithSign_fx( singularVectors_Left[nCh][nCh + 1] ), &temp_exp1 ); /* exp(temp_exp1) */ singularVectors_Right[iCh][nCh] = BASOP_Util_Divide3232_Scale_cadence( ratio_float, maxWithSign_fx( t_ii ), &sing_right_exp[iCh][nCh] ); /* exp(sing_right_exp + (temp_exp1 - secDiag_e) */ #endif move32(); sing_right_exp[iCh][nCh] = add( sing_right_exp[iCh][nCh], sub( temp_exp1, secDiag_e ) ); move16(); Loading