Commit d78bb97e authored by Nicolas Roussin's avatar Nicolas Roussin
Browse files

Do not right shift.

parent 99e842f2
Loading
Loading
Loading
Loading
Loading
+20 −12
Original line number Diff line number Diff line
@@ -1492,8 +1492,13 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
    rsh0 = (Word16) ( ceil_log2( hSpatParamRendCom->subframe_nbslots[subframe] ) - 1 );
    rsh1 = (Word16) ( ceil_log2( BINAURAL_CHANNELS * hSpatParamRendCom->subframe_nbslots[subframe] ) - 1 );
#if 1
    exp0 = sub( 63, shl( q, 1 ) );
    exp1 = sub( 63, shl( q, 1 ) );
#else
    exp0 = add( sub( 63, shl( q, 1 ) ), rsh0 );
    exp1 = add( sub( 63, shl( q, 1 ) ), rsh1 );
#endif
#else
    exp = sub( 63, shl( q, 1 ) ); // exp for the energy (inRe_fx * inRe_fx + inIm_fx * inIm_fx) computed below
#endif
@@ -1508,8 +1513,13 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
                temp64 = W_mult0_32_32( inRe_fx[ch][slot][bin], inRe_fx[ch][slot][bin] );                  // 2q
                temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[ch][slot][bin], inIm_fx[ch][slot][bin] ) ); // 2q
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
#if 1
                hDiracDecBin->ChEne[ch][bin] = W_add( hDiracDecBin->ChEne[ch][bin], temp64 ); // 2q
                subFrameTotalEne[bin] = W_add( subFrameTotalEne[bin], temp64 );               // 2q
#else
                hDiracDecBin->ChEne[ch][bin] = W_add( hDiracDecBin->ChEne[ch][bin], W_shr( temp64, rsh0 ) ); // 2q - rsh0
                subFrameTotalEne[bin] = W_add( subFrameTotalEne[bin], W_shr( temp64, rsh1 ) );               // 2q - rsh1
#endif
                move64();
                move64();
#else
@@ -1526,7 +1536,11 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
            temp64 = W_mult0_32_32( inRe_fx[0][slot][bin], inRe_fx[1][slot][bin] );                  // 2q
            temp64 = W_add( temp64, W_mult0_32_32( inIm_fx[0][slot][bin], inIm_fx[1][slot][bin] ) ); // 2q
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
#if 1
            hDiracDecBin->ChCrossRe[bin] = W_add( hDiracDecBin->ChCrossRe[bin], temp64 ); // 2q
#else
            hDiracDecBin->ChCrossRe[bin] = W_add( hDiracDecBin->ChCrossRe[bin], W_shr( temp64, rsh0 ) ); // 2q - rsh0
#endif
            move64();
#else
            exp1 = W_norm( temp64 );
@@ -1538,7 +1552,11 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
            temp64 = W_mult0_32_32( inRe_fx[0][slot][bin], inIm_fx[1][slot][bin] );                  // 2q
            temp64 = W_sub( temp64, W_mult0_32_32( inIm_fx[0][slot][bin], inRe_fx[1][slot][bin] ) ); // 2q
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
#if 1
            hDiracDecBin->ChCrossIm[bin] = W_add( hDiracDecBin->ChCrossIm[bin], temp64 ); // 2q
#else
            hDiracDecBin->ChCrossIm[bin] = W_add( hDiracDecBin->ChCrossIm[bin], W_shr( temp64, rsh0 ) ); // 2q - rsh0
#endif
            move64();
#else
            exp1 = W_norm( temp64 );
@@ -1652,25 +1670,15 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx(
#ifdef NONBE_2157_IVAS_DIRAC_DEC_BINAURAL_FORMULATE_INPUT_COVARIANCE_MATRICES
        Word16 exp;
        Word64 num64, den64;
#if 0
        num64 = W_add( W_shr( hDiracDecBin->ChEne[0][bin], 1 ), W_shr( hDiracDecBin->ChEne[1][bin], 1 ) );         // 2q - rsh0 - 1
        num64 = Mpy_64_32( num64, IIReneLimiterFactor_fx );                                                        // 2q - rsh0 - 1 - 5
        den64 = W_add( W_shr( hDiracDecBin->ChEnePrev[0][bin], 1 ), W_shr( hDiracDecBin->ChEnePrev[1][bin], 1 ) ); // 2q - rsh0 - 1
#else
        num64 = W_add( hDiracDecBin->ChEne[0][bin], hDiracDecBin->ChEne[1][bin] );         // 2q - rsh0
        num64 = Mpy_64_32( num64, IIReneLimiterFactor_fx );                                // 2q - rsh0 - 5
        den64 = W_add( hDiracDecBin->ChEnePrev[0][bin], hDiracDecBin->ChEnePrev[1][bin] ); // 2q - rsh0
#endif
        den64 = W_max( 1, den64 );
        num_e = W_norm( num64 );
        den_e = W_norm( den64 );
        num = W_extract_h( W_shl( num64, num_e ) ); // 2q - rsh0 - 1 - 5 + num_e - 32
        den = W_extract_h( W_shl( den64, den_e ) ); // 2q - rsh0 - 1 + den_e - 32
#if 0
        num = W_extract_h( W_shl( num64, num_e ) ); // 2q - rsh0 - 5 + num_e - 32
        den = W_extract_h( W_shl( den64, den_e ) ); // 2q - rsh0 + den_e - 32
        IIReneLimiter_fx[bin] = BASOP_Util_Divide3232_Scale_newton( num, den, &exp );
#else
        IIReneLimiter_fx[bin] = BASOP_Util_Divide3232_Scale_cadence( num, den, &exp );
#endif
        exp = add( sub( den_e, num_e ), add( 5, exp ) );
        IF( L_shr_sat( IIReneLimiter_fx[bin], sub( 31, exp ) ) > 0 )
        {