Commit e0ae5f5e authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Stereo, ISM and MASA LTV crash issue fixes

parent 53ba9d7c
Loading
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -258,8 +258,8 @@ void Inac_switch_ematch_ivas_fx(
                FOR(j = 0; j < 8; j++)
                {
                    L_tmp = L_mult0(*pt_exc, ftmp);
                    L_tmp = L_shl(L_tmp, add(exp, 15));  /* Q(Q_exc) -> Q(15+Q_exc)*/
                    *pt_exc = round_fx(L_tmp);           /*Q_exc - 1*/
                    L_tmp = L_shl_sat(L_tmp, add(exp, 15));  /* Q(Q_exc) -> Q(15+Q_exc)*/
                    *pt_exc = round_fx_sat(L_tmp);           /*Q_exc - 1*/
                    pt_exc++;
                }
            }
@@ -268,8 +268,8 @@ void Inac_switch_ematch_ivas_fx(
                FOR(j = 0; j < 16; j++)
                {
                    L_tmp = L_mult0(*pt_exc,ftmp);
                    L_tmp = L_shl(L_tmp, add(exp,15));  /* Q(Q_exc) -> Q(15+Q_exc)*/
                    *pt_exc = round_fx(L_tmp);          /*Q_exc - 1*/
                    L_tmp = L_shl_sat(L_tmp, add(exp,15));  /* Q(Q_exc) -> Q(15+Q_exc)*/
                    *pt_exc = round_fx_sat(L_tmp);          /*Q_exc - 1*/
                    pt_exc++;
                }
            }
+12 −0
Original line number Diff line number Diff line
@@ -4763,6 +4763,18 @@ Word16 matrix_product_fx(
    Word32 *Z_fx                                                    /* o  : resulting matrix after the matrix multiplication                                       */
);

Word16 matrix_product_q30_fx(
    const Word32 *X_fx,   /* i  : left hand matrix                                                                       */
    const Word16 rowsX,   /* i  : number of rows of the left hand matrix                                                 */
    const Word16 colsX,   /* i  : number of columns of the left hand matrix                                              */
    const Word16 transpX, /* i  : flag indicating the transposition of the left hand matrix prior to the multiplication  */
    const Word32 *Y_fx,   /* i  : right hand matrix                                                                      */
    const Word16 rowsY,   /* i  : number of rows of the right hand matrix                                                */
    const Word16 colsY,   /* i  : number of columns of the right hand matrix                                             */
    const Word16 transpY, /* i  : flag indicating the transposition of the right hand matrix prior to the multiplication */
    Word32 *Z_fx          /* o  : resulting matrix after the matrix multiplication                                       */
);

Word16 matrix_product_mant_exp(
  const Word32 *X_fx,    /* i  : left hand matrix                                                                       */
  const Word16 *X_e,     /* i  : left hand matrix                                                                       */
+1 −1
Original line number Diff line number Diff line
@@ -509,7 +509,7 @@ void tdm_bit_alloc(
            IF( coder_type == INACTIVE )
            {
                Word32 res_fix = 0;
                res_fix = Mpy_32_32(644245094, ( element_brate_wo_meta - 500 ) );
                res_fix = Mpy_32_32(644245095, ( element_brate_wo_meta - 500 ) );
                res_fix = ( ( res_fix / 100 ) * 100 );
                *total_brate_sec = max( *total_brate_sec, res_fix );

+121 −0
Original line number Diff line number Diff line
@@ -1354,6 +1354,127 @@ Word16 matrix_product_fx(
    return EXIT_SUCCESS;
}

Word16 matrix_product_q30_fx(
    const Word32 *X_fx,   /* i  : left hand matrix                                                                       */
    const Word16 rowsX,   /* i  : number of rows of the left hand matrix                                                 */
    const Word16 colsX,   /* i  : number of columns of the left hand matrix                                              */
    const Word16 transpX, /* i  : flag indicating the transposition of the left hand matrix prior to the multiplication  */
    const Word32 *Y_fx,   /* i  : right hand matrix                                                                      */
    const Word16 rowsY,   /* i  : number of rows of the right hand matrix                                                */
    const Word16 colsY,   /* i  : number of columns of the right hand matrix                                             */
    const Word16 transpY, /* i  : flag indicating the transposition of the right hand matrix prior to the multiplication */
    Word32 *Z_fx          /* o  : resulting matrix after the matrix multiplication                                       */
)
{
    Word16 i, j, k;
    Word32 *Zp_fx = Z_fx;
    Word64 W_tmp;

    /* Processing */
    test();
    test();
    test();
    IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 0 ) ) /* We use X transpose */
    {
        IF( NE_16( rowsX, rowsY ) )
        {
            return EXIT_FAILURE;
        }
        FOR( j = 0; j < colsY; ++j )
        {
            FOR( i = 0; i < colsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < rowsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[k + j * rowsY] ) );//Q56
                }
                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub(W_round64_L( W_tmp ), 64); //adjusting for precision
                Zp_fx++;
            }
        }
    }
    ELSE IF( EQ_16( transpX, 0 ) && EQ_16( transpY, 1 ) ) /* We use Y transpose */
    {
        IF( NE_16( colsX, colsY ) )
        {
            return EXIT_FAILURE;
        }
        FOR( j = 0; j < rowsY; ++j )
        {
            FOR( i = 0; i < rowsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < colsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
                }
                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
                Zp_fx++;
            }
        }
    }
    ELSE IF( EQ_16( transpX, 1 ) && EQ_16( transpY, 1 ) ) /* We use both transpose */
    {
        IF( NE_16( rowsX, colsY ) )
        {
            return EXIT_FAILURE;
        }
        FOR( j = 0; j < rowsY; ++j )
        {
            FOR( i = 0; i < colsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < colsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[k + i * rowsX], Y_fx[j + k * rowsY] ) ); // Q56
                }

                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
                Zp_fx++;
            }
        }
    }
    ELSE /* Regular case */
    {
        IF( NE_16( colsX, rowsY ) )
        {
            return EXIT_FAILURE;
        }

        FOR( j = 0; j < colsY; ++j )
        {
            FOR( i = 0; i < rowsX; ++i )
            {
                //( *Zp_fx ) = 0;
                W_tmp = 0;
                move64();
                FOR( k = 0; k < colsX; ++k )
                {
                    //( *Zp_fx ) = L_add( *Zp_fx, Mpy_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) );
                    W_tmp = W_add( W_tmp, W_mult0_32_32( X_fx[i + k * rowsX], Y_fx[k + j * rowsY] ) ); // Q56
                }
                W_tmp = W_shl( W_tmp, 6 );
                ( *Zp_fx ) = L_sub( W_round64_L( W_tmp ), 64 ); // adjusting for precision
                Zp_fx++;
            }
        }
    }

    return EXIT_SUCCESS;
}
/*takes input matrices in mantissa and exponent forms*/
Word16 matrix_product_mant_exp(
    const Word32 *X_fx,   /* i  : left hand matrix                                                                       */
+28 −9
Original line number Diff line number Diff line
@@ -1760,7 +1760,10 @@ Word16 ApplyFdCng_ivas_fx(
                        }
                        s2 = s_max( s2, facTabExp[k] );
                    }

                    IF(EQ_16(s2, -31))
                    {
                      s2 = 0; move16();
                    }
                    FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
                    {
                        s = sub( facTabExp[k], s2 );
@@ -1833,7 +1836,10 @@ Word16 ApplyFdCng_ivas_fx(
                        }
                        s2 = s_max( s2, facTabExp[k] );
                    }

                    IF(EQ_16(s2, -31))
                    {
                      s2 = 0; move16();
                    }
                    FOR( k = 0; k < hFdCngCom->nFFTpart; k++ )
                    {
                        s = sub( facTabExp[k], s2 );
@@ -2705,27 +2711,40 @@ void perform_noise_estimation_dec_ivas_fx(
                Word16 scale;
                /* no updates during active frames except for significant energy drops */
                enr_ratio = BASOP_Util_Divide3232_Scale( enr_tot, enr_tot0, &scale );
                IF( GE_16( scale, 0 ) )
                IF( LE_16( scale, 0 ) )
                {
                    enr_ratio = shr( enr_ratio, scale );
                    enr_ratio = shl( enr_ratio, scale );
                    scale = 15; move16();
                }
                ELSE
                {
                    enr_ratio = shr( enr_ratio, sub( 15, scale ) );
                    scale = sub(15, scale);
                }
                IF( LT_16( enr_ratio, ONE_IN_Q14 ) )
                IF( LT_16( enr_ratio, shl(1, sub(scale, 1)) ) )
                {
                    /* total energy significantly decreases during active frames -> downward update */
                    wght = lin_interp_fx( enr_ratio, 0, 26214 /*0.8f in Q15*/, 16384 /*0.5f in Q15*/, 31130 /*0.95f in Q15*/, 32767 /*1 in Q15*/ );

                    wght = lin_interp_fx( enr_ratio, 0, shr(26214, sub(15, scale)) /*0.8f in Q15*/, shr(16384, sub(15, scale)) /*0.5f in Q15*/, shr(31130, sub(15, scale)) /*0.95f in Q15*/, shr(32767, sub(15, scale)) /*1 in Q15*/ );
                    Word16 temp_q_msNoiseEst[NPART_SHAPING];
                    Word16 min_q_msNoiseEst = MAX_16;
                    FOR(p = 0; p < NPART_SHAPING; p++)
                    {
                      temp_q_msNoiseEst[p] = hFdCngDec->msNoiseEst_exp; move16();
                    }
                    FOR( p = 0; p < npart; p++ )
                    {
                        L_tmp = L_shr( msPeriodog[p], sub( sub( 31, hFdCngDec->hFdCngCom->periodog_exp ), 4 ) );
                        IF( LT_32( L_tmp, msNoiseEst[p] ) )
                        {
                            msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], wght ), Mpy_32_16_1( L_tmp, (Word16) L_sub( ONE_IN_Q15, wght ) ) );
                            msNoiseEst[p] = L_add( Mpy_32_16_1( msNoiseEst[p], wght ), Mpy_32_16_1( L_tmp, (Word16) L_sub( shr(MAX_16, sub(15, scale)), wght ) ) );
                            temp_q_msNoiseEst[p] = sub(add(hFdCngDec->msNoiseEst_exp, scale), 15);
                        }
                        min_q_msNoiseEst = s_min(temp_q_msNoiseEst[p], min_q_msNoiseEst);
                    }
                    FOR(p = 0; p < NPART_SHAPING; p++)
                    {
                      msNoiseEst[p] = L_shl(msNoiseEst[p], sub(min_q_msNoiseEst, temp_q_msNoiseEst[p]));
                    }
                    hFdCngDec->msNoiseEst_exp = min_q_msNoiseEst; move16();
                }
                ELSE
                {
Loading