Commit 8f5ded95 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Stereo crash fixes

parent 15656fb4
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++;
                }
            }
+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
                {