Commit 3d4448f8 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'ltv_crash_fixes_mld_improvements' into 'main'

Fix for ltv crashes and changes for mld improvements

See merge request !545
parents d887ee75 0f8b3f05
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2251,7 +2251,7 @@ static void ivas_subst_spec_fx(
        tmp = sub( tmp, ph_ecu_lookahead );
        tmp = add( tmp, sub( Lecu, shr( sub( Lecu, Lprot ), 1 ) ) );
        tmp = sub( tmp, shr( output_frame, 1 ) );
        tmp1 = L_add( L_mult0( tmp, Lprot_inv ), L_mult0( time_offs, Lprot_inv ) ); /* Q22 */
        tmp1 = L_mac0( L_mult0( tmp, Lprot_inv ), time_offs, Lprot_inv ); /* Q22 */

        pPlocsi = plocsi;
        pCorrPhase = corr_phase;
+17 −4
Original line number Diff line number Diff line
@@ -2468,15 +2468,15 @@ void perform_noise_estimation_dec_ivas_fx(
        SWITCH( hFdCngDec->hFdCngCom->fftlen )
        {
            case 640:
                rescale_fac = 671089; // 4/(640 * 640) in Q36
                rescale_fac = 335544; // 4/(640 * 640) in Q35
                move32();
                BREAK;
            case 512:
                rescale_fac = 1048576; // 4/(512 * 512) in Q36
                rescale_fac = 524288; // 4/(512 * 512) in Q35
                move32();
                BREAK;
            case 320:
                rescale_fac = 2684354; // 4/(320 * 320) in Q36
                rescale_fac = 1342177; // 4/(320 * 320) in Q35
                move32();
                BREAK;
            default:
@@ -2538,7 +2538,7 @@ void perform_noise_estimation_dec_ivas_fx(
            ptr_i += 2;
        }

        hFdCngDec->hFdCngCom->periodog_exp = sub( 31 - 5, min_q );
        hFdCngDec->hFdCngCom->periodog_exp = sub( 31 - 4, min_q );
        hFdCngDec->hFdCngCom->fftBuffer_exp = fftBuffer_exp;
        move16();
        move16();
@@ -2581,6 +2581,19 @@ void perform_noise_estimation_dec_ivas_fx(
        {
            i = 0;
            move16();

            /* This is done to avoid overflow when checking "if ( msPeriodog[p] < 1e-5f )" */
            IF( LT_16( hFdCngDec->msPeriodog_exp, -16 ) )
            {
                FOR( p = 0; p < NPART_SHAPING; p++ )
                {
                    msPeriodog[p] = L_shr( msPeriodog[p], sub( -16, hFdCngDec->msPeriodog_exp ) );
                    move32();
                }
                hFdCngDec->msPeriodog_exp = -16;
                move16();
            }

            FOR( p = 0; p < npart; p++ )
            {
                /* calculate variance over all bins in power partition */
+7 −65
Original line number Diff line number Diff line
@@ -3499,14 +3499,13 @@ void ivas_param_mc_dec_render_fx(
                    move16();
                }
            }
        }

            IF( is_zero )
            {
                hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[j] = 0;
                move16();
            }
        }
    }
    FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ )
    {
        FOR( slot_idx = 0; slot_idx < hParamMC->subframe_nbslots[subframe_idx]; ( slot_idx++, hParamMC->slots_rendered++ ) )
@@ -5078,8 +5077,6 @@ static void ivas_param_mc_get_mixing_matrices_fx(
    Word16 proto_matrix_noLFE_e = 0;
    move16();

    Word16 guard_bit_cx = find_guarded_bits_fx( nY_intern + 1 );
    Word16 guard_bit_cy = find_guarded_bits_fx( nY_cov * nY_cov );
    Word32 Cx_in_fx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];


@@ -5213,39 +5210,8 @@ static void ivas_param_mc_get_mixing_matrices_fx(
            /* smoothing gains are now identical to one, simply add up */
            // v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov );

            tmp_e = add( s_max( hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], Cx_state_e ), guard_bit_cx );
            FOR( i = 0; i < nX * nX; i++ )
            {
                Cx_old_state_fx[i] = L_shr( Cx_old_state_fx[i], sub( tmp_e, hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] ) );
                move32();
                Cx_state_fx[i] = L_shr( Cx_state_fx[i], sub( tmp_e, Cx_state_e ) );
                move32();
            }

            hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx] = tmp_e;
            move16();
            Cx_state_e = tmp_e;
            move16();
            tmp_e = add( s_max( hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], Cy_state_e ), guard_bit_cy );
            FOR( i = 0; i < imult1616( nY_cov, nY_cov ); i++ )
            {
                Cy_old_state_fx[i] = L_shr( Cy_old_state_fx[i], sub( tmp_e, hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] ) );
                move32();
                Cy_state_fx[i] = L_shr( Cy_state_fx[i], sub( tmp_e, Cy_state_e ) );
                move32();
            }

            hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx] = tmp_e;
            Cy_state_e = tmp_e;
            move16();

            v_add_32( Cx_state_fx, Cx_old_state_fx, Cx_fx, imult1616( nX, nX ) );
            v_add_32( Cy_state_fx, Cy_old_state_fx, Cy_full_fx, imult1616( nY_cov, nY_cov ) );

            Cy_full_e = Cy_state_e;
            move16();
            Cx_e = Cx_state_e;
            move16();
            v_add_fixed_me( Cx_state_fx, Cx_state_e, Cx_old_state_fx, hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], Cx_fx, &Cx_e, imult1616( nX, nX ), 1 );
            v_add_fixed_me( Cy_state_fx, Cy_state_e, Cy_old_state_fx, hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], Cy_full_fx, &Cy_full_e, imult1616( nY_cov, nY_cov ), 1 );
        }

        Copy32( Cx_state_fx, Cx_old_state_fx, imult1616( nX, nX ) );
@@ -5304,32 +5270,8 @@ static void ivas_param_mc_get_mixing_matrices_fx(
        matrix_product_fx( proto_matrix_ptr_fx, nY_band, nX, 0, Cx_fx, nX, nX, 0, mat_mult_buffer1_fx );
        mat_mult_buffer1_e = add( proto_matrix_ptr_e, Cx_e );

        Word16 guard_bits = find_guarded_bits_fx( add( nY_band, 1 ) );

        FOR( i = 0; i < imult1616( nY_band, nX ); ++i )
        {
            proto_matrix_ptr_fx[i] = L_shr( proto_matrix_ptr_fx[i], guard_bits );
            move32();
            mat_mult_buffer1_fx[i] = L_shr( mat_mult_buffer1_fx[i], guard_bits );
            move32();
        }

        proto_matrix_ptr_e = add( proto_matrix_ptr_e, guard_bits );
        mat_mult_buffer1_e = add( mat_mult_buffer1_e, guard_bits );

        matrix_product_diag_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, nY_band, nX, 0, proto_matrix_ptr_fx, proto_matrix_ptr_e, nY_band, nX, 1, Cproto_diag_fx, &Cproto_diag_e );

        FOR( i = 0; i < imult1616( nY_band, nX ); ++i )
        {
            proto_matrix_ptr_fx[i] = L_shl( proto_matrix_ptr_fx[i], guard_bits );
            move32();
            mat_mult_buffer1_fx[i] = L_shl( mat_mult_buffer1_fx[i], guard_bits );
            move32();
        }

        proto_matrix_ptr_e = sub( proto_matrix_ptr_e, guard_bits );
        mat_mult_buffer1_e = sub( mat_mult_buffer1_e, guard_bits );

        /* make sure we have no negative entries in Cproto_diag due to rounding errors */

        FOR( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ )
+1 −1
Original line number Diff line number Diff line
@@ -2103,7 +2103,7 @@ void ivas_mdct_core_reconstruct_fx(
            }
            decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, NULL, bfi, MCT_flag );

            sf = getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) );
            sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) );
            IF( LT_16( sf, 2 ) )
            {
                q_syn = sub( sf, 2 );
+7 −1
Original line number Diff line number Diff line
@@ -1234,6 +1234,8 @@ void ivas_sba_dirac_stereo_dec_fx(
    Word32 DFT[CPE_CHANNELS][STEREO_DFT_BUF_MAX];
    Word16 q_dft[2] = { 0, 0 };
    Word16 q = 0;
    Word16 q_synth = 0;
    move16();
    SCE_DEC_HANDLE hSCE;
    CPE_DEC_HANDLE hCPE;
    STEREO_DFT_DEC_DATA_HANDLE hStereoDft;
@@ -1309,6 +1311,10 @@ void ivas_sba_dirac_stereo_dec_fx(

        /* do updates here after skipping this in SCE decoder (needs to be done after core switching) */
        ivas_updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, hSCE->save_synth_fx, q );

        q_synth = sub( getScaleFactor32( tmp_synth, hSCE->hCoreCoder[0]->L_frame ), 10 );
        scale_sig32( tmp_synth, hSCE->hCoreCoder[0]->L_frame, q_synth );
        q_synth = add( q_synth, hSCE->q_save_synth_fx );
    }

    /* mapping of DirAC parameters (azimuth, elevation, diffuseness) to DFT Stereo parameters (side gain, prediction gain) */
@@ -1318,7 +1324,7 @@ void ivas_sba_dirac_stereo_dec_fx(
    test();
    map_params_dirac_to_stereo( hStereoDft, st_ivas->hQMetaData, tmp_synth, DFT[0], st_ivas->ivas_format == MC_FORMAT,
                                ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ) ? hSCE->hCoreCoder[0]->L_frame : output_frame,
                                ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), hSCE != NULL ? hSCE->q_save_synth_fx : 0 );
                                ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), hSCE != NULL ? q_synth : 0 );

    IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa )
    {