Commit 2ea712ad authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

LTV fixes for OMASA crashes

parent cc1650aa
Loading
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -740,19 +740,36 @@ ivas_error decod_gen_voic_ivas_fx(
                Word32 Ltmp1;
                /* Contribution from AVQ layer */
                Ltmp1 = L_mult(gain_preQ_fx, code_preQ_fx[i]);    /* Q2 + Q6 -> Q9*/
#ifdef BASOP_NOGLOB
                Ltmp1 = L_shl_sat(Ltmp1, tmp1_fx);                     /* Q16 + Q_exc */
#else
                Ltmp1 = L_shl(Ltmp1, tmp1_fx);                     /* Q16 + Q_exc */
#endif

                /* Compute exc2 */
#ifdef BASOP_NOGLOB
                L_tmp = L_shl_sat(L_mult(gain_pit_fx, exc_fx[i + i_subfr_fx]), 1);
                exc2_fx[i + i_subfr_fx] = round_fx_sat(L_add_sat(L_tmp, Ltmp1));
#else
                L_tmp = L_shl(L_mult(gain_pit_fx, exc_fx[i + i_subfr_fx]), 1);
                exc2_fx[i + i_subfr_fx] = round_fx(L_add(L_tmp, Ltmp1));
#endif

                /* code in Q9, gain_pit in Q14 */
                L_tmp = L_mult(gain_code16, code_fx[i]);
#ifdef BASOP_NOGLOB
                L_tmp = L_shl_sat(L_tmp, 5);
                L_tmp = L_mac_sat(L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx);
                L_tmp = L_shl_sat(L_tmp, 1); /* saturation can occur here */

                exc_fx[i + i_subfr_fx] = round_fx_sat(L_add_sat(L_tmp, Ltmp1));
#else
                L_tmp = L_shl(L_tmp, 5);
                L_tmp = L_mac(L_tmp, exc_fx[i + i_subfr_fx], gain_pit_fx);
                L_tmp = L_shl(L_tmp, 1); /* saturation can occur here */

                exc_fx[i + i_subfr_fx] = round_fx(L_add(L_tmp, Ltmp1));
#endif
            }
        }
        ELSE
+1 −1
Original line number Diff line number Diff line
@@ -615,7 +615,7 @@ ivas_error ivas_cpe_dec_fx(

        IF( shift != 31 )
        {
            shift = hCPE->hStereoDft->q_dft + shift - Q11; /* Q11 for guard bits */
            shift = hCPE->hStereoDft->q_dft + shift - Q13; /* Q13 for guard bits */

            IF( shift > hCPE->hStereoDft->q_dft )
            {
+8 −2
Original line number Diff line number Diff line
@@ -4952,8 +4952,14 @@ void ivas_dirac_dec_render_sf_fx(
        {
            st_ivas->hMasa->data.dir_decode_quality_fx = float_to_fix16( st_ivas->hMasa->data.dir_decode_quality, Q15 );

            qualityBasedSmFactor_fx = L_deposit_h( st_ivas->hMasa->data.dir_decode_quality_fx );  // Q31
            qualityBasedSmFactor_fx = Mpy_32_32( qualityBasedSmFactor_fx, qualityBasedSmFactor_fx ); // (Q31, Q31) -> Q31
            IF( EQ_16( st_ivas->hMasa->data.dir_decode_quality_fx, MAX_16 ) )
            {
                qualityBasedSmFactor_fx = MAX_32;
            }
            ELSE
            {
                qualityBasedSmFactor_fx = L_mult( st_ivas->hMasa->data.dir_decode_quality_fx, st_ivas->hMasa->data.dir_decode_quality_fx ); // (Q15, Q15) -> Q31
            }
        }
#else
        float qualityBasedSmFactor = 1.0f;
+1 −1
Original line number Diff line number Diff line
@@ -2067,7 +2067,7 @@ void stereo_dft_dec_fx(
                    gamma = 0;
                }

                FOR ( i = s_max( hFdCngDec->cna_band_limits[b], shr(hFdCngCom->startBand , 2) ); i < s_min( hFdCngDec->cna_band_limits[b + 1], (L_FRAME16k) >> 1 ); i++ )
                FOR ( i = s_max( hFdCngDec->cna_band_limits[b], shr(hFdCngCom->startBand , 1) ); i < s_min( hFdCngDec->cna_band_limits[b + 1], (L_FRAME16k) >> 1 ); i++ )
                {
                    Word32 l_tmp;
                    lev1 = *ptr_per++;
+18 −14
Original line number Diff line number Diff line
@@ -3251,7 +3251,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
        subtract_power_y = masa_stereo_type_detect->subtract_power_y_fx; // q_subtract_power_y
        move32();

        a = (Word32) ( 0.0004f * ONE_IN_Q31 ); /* Temporal smoothing coefficient */
        a = 858993;                 /* ( 0.0004f in Q31 ); Temporal smoothing coefficient */
        b = L_sub( ONE_IN_Q31, a ); /* Temporal smoothing coefficient */

        q_com = s_min( exp, masa_stereo_type_detect->q_target_power_y_smooth );
@@ -3269,16 +3269,20 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(

        exp = 0;
        move16();
        tmp = BASOP_Util_Divide3232_Scale( masa_stereo_type_detect->subtract_power_y_smooth_fx,
                                           L_add( masa_stereo_type_detect->target_power_y_smooth_fx, EPSILON_FX ),
                                           &exp );
        exp = add( sub( Q15, exp ), sub( masa_stereo_type_detect->q_subtract_power_y, q_com ) );
        subtract_target_ratio = L_shl( L_deposit_l( tmp ), sub( Q15, exp ) ); // Q15

        L_tmp = BASOP_Util_Log2( subtract_target_ratio );        // Q25
        L_tmp = L_add( L_tmp, L_shl( L_sub( Q31, Q15 ), Q25 ) ); // Q25
        subtract_target_ratio_db = Mpy_32_32( (Word32) ( 10.0f * ONE_IN_Q27 ),
                                              Mpy_32_32( L_tmp, LOG10_2_Q31 ) ); // (Q27, (Q25, Q31)) -> (Q27, Q25) -> Q21
        IF( NE_32( masa_stereo_type_detect->target_power_y_smooth_fx, 0 ) )
        {
            subtract_target_ratio = L_sub( BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ),
                                           BASOP_Util_Log2( masa_stereo_type_detect->target_power_y_smooth_fx ) ); // Q25
            exp = sub( masa_stereo_type_detect->q_subtract_power_y, q_com );
            L_tmp = Mpy_32_32( L_sub( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ); // Q25
        }
        ELSE
        {
            subtract_target_ratio = BASOP_Util_Log2( masa_stereo_type_detect->subtract_power_y_smooth_fx ); // Q25
            exp = sub( 31, masa_stereo_type_detect->q_subtract_power_y );
            L_tmp = L_sub( Mpy_32_32( L_add( subtract_target_ratio, L_shl( exp, 25 ) ), LOG10_2_Q31 ), L_shl( -15, 25 ) /*log(EPSILON)*/ ); // Q25
        }
        subtract_target_ratio_db = Mpy_32_32( 1342177280 /* 10.0f * in Q27*/, L_tmp ); // (Q27, (Q25, Q31)) -> (Q27, Q25) -> Q21

        masa_stereo_type_detect->subtract_target_ratio_db_fx = subtract_target_ratio_db; // Q21
        move32();
@@ -3300,7 +3304,7 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx(
        Word32 instDirectionSmoothness, weightedDirectionSmoothness, smoothedDirectionSmoothness;
        Word32 currWeight, prevWeight, sumWeight;
        Word16 indexFast, indexSlow;
        Word32 alpha_quality_based = (Word32) ( 0.02f * ONE_IN_Q31 );
        Word32 alpha_quality_based = 42949672; /* 0.02f in Q31 */
        move32();

        indexSlow = s_min( l, alphaMaxBin );
@@ -4802,7 +4806,7 @@ void ivas_dirac_dec_compute_directional_responses_fx(
                            ismDirect_fx = L_add( ismDirect_fx, hMasaIsm->energy_ratio_ism_fx[dir][md_idx][k] );
                        }

                        totalDirect_fx = L_add( masaDirect_fx, ismDirect_fx );
                        totalDirect_fx = L_add_sat( masaDirect_fx, ismDirect_fx ); // saturating as 1.0 (Q30) + 1.0 (Q30) is observed 
                        Word16 var_a = 0, var_b = 0;
                        var_a = BASOP_Util_Divide3232_Scale( masaDirect_fx, totalDirect_fx, &exp_1 );
                        var_b = BASOP_Util_Divide3232_Scale( ismDirect_fx, totalDirect_fx, &exp_2 );