Commit ffeb27b7 authored by mave2802's avatar mave2802
Browse files

increased accuracy for mixing matrix calculation by using seperate...

increased accuracy for mixing matrix calculation by using seperate scalefactors for ref_power and cx_diag for each freq band (to avoid holes especially in the upper freq band region)
parent d68c8f84
Loading
Loading
Loading
Loading
+31 −60
Original line number Diff line number Diff line
@@ -177,25 +177,17 @@ static void ivas_param_ism_collect_slot_fx(
    Word16 exp_imag,
    const Word16 ch,
    Word32 ref_power_fx[], /*Q(31-exp_ref_power)*/
    Word16 *exp_ref_power,
    Word16 exp_ref_power[],
    Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-exp_cx_diag)*/
    Word16 *exp_cx_diag )
    Word16 exp_cx_diag[][PARAM_ISM_MAX_DMX] )
{
    Word16 band_idx, bin_idx;
    Word16 brange[2];
    Word32 tmp_fx;
    Word16 exp_tmp;
    Word16 i, j;

    /* loop over parameter bands to collect transport channel energies */

    Word16 exp_ref_power_buf[CLDFB_NO_CHANNELS_MAX];
    Word16 exp_cx_diag_buf[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
    set16_fx( exp_ref_power_buf, *exp_ref_power, CLDFB_NO_CHANNELS_MAX );
    FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
    {
        set16_fx( exp_cx_diag_buf[i], *exp_cx_diag, PARAM_ISM_MAX_DMX );
    }
    FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ )
    {
        brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx];
@@ -216,50 +208,19 @@ static void ivas_param_ism_collect_slot_fx(
            Word16 exp_cx_diag_new = 0, exp_ref_power_new = 0;
            move16();
            move16();
            cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], exp_cx_diag_buf[bin_idx][ch], tmp_fx, exp_tmp, &exp_cx_diag_new );
            cx_diag_fx[bin_idx][ch] = BASOP_Util_Add_Mant32Exp( cx_diag_fx[bin_idx][ch], exp_cx_diag[bin_idx][ch], tmp_fx, exp_tmp, &exp_cx_diag_new );
            move32();
            ref_power_fx[bin_idx] = BASOP_Util_Add_Mant32Exp( ref_power_fx[bin_idx], exp_ref_power_buf[bin_idx], tmp_fx, exp_tmp, &exp_ref_power_new );
            ref_power_fx[bin_idx] = BASOP_Util_Add_Mant32Exp( ref_power_fx[bin_idx], exp_ref_power[bin_idx], tmp_fx, exp_tmp, &exp_ref_power_new );
            move32();
            exp_cx_diag_buf[bin_idx][ch] = exp_cx_diag_new;
            exp_cx_diag[bin_idx][ch] = exp_cx_diag_new;
            move16();
            exp_ref_power_buf[bin_idx] = exp_ref_power_new;
            exp_ref_power[bin_idx] = exp_ref_power_new;
            move16();
        }
    }

    /*make common exponent*/
    Word16 max_exp_cx_diag = exp_cx_diag_buf[0][0], max_exp_ref_power = exp_ref_power_buf[0];
    move16();
    move16();
    FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
    {
        FOR( j = 0; j < PARAM_ISM_MAX_DMX; j++ )
        {
            max_exp_cx_diag = s_max( max_exp_cx_diag, exp_cx_diag_buf[i][j] );
        }
        max_exp_ref_power = s_max( max_exp_ref_power, exp_ref_power_buf[i] );
    }

    FOR( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ )
    {
        FOR( j = 0; j < PARAM_ISM_MAX_DMX; j++ )
        {
            cx_diag_fx[i][j] = L_shr_r( cx_diag_fx[i][j], sub( max_exp_cx_diag, exp_cx_diag_buf[i][j] ) ); // Q(31-max_exp_cx_diag)
            move32();
        }
        ref_power_fx[i] = L_shr_r( ref_power_fx[i], sub( max_exp_ref_power, exp_ref_power_buf[i] ) ); // Q(31-max_exp_ref_power)
        move16();
    }

    *exp_cx_diag = max_exp_cx_diag;
    move16();
    *exp_ref_power = max_exp_ref_power;
    move16();

    return;
}


static void ivas_param_ism_compute_mixing_matrix_fx(
    const Word16 nchan_ism,                                         /* i  : number of ISM channels       */
    PARAM_ISM_DEC_HANDLE hParamIsmDec,                              /* i/o: decoder ParamISM handle */
@@ -268,9 +229,9 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
    const Word16 nchan_transport,
    const Word16 nchan_out_woLFE,
    Word32 cx_diag_fx[][PARAM_ISM_MAX_DMX], /*Q(31-cx_diag_e)*/
    Word16 cx_diag_e,
    Word16 cx_diag_e[][PARAM_ISM_MAX_DMX],
    Word32 ref_power_fx[], /*Q(31-ref_power_e)*/
    Word16 ref_power_e,
    Word16 ref_power_e[],
    Word32 mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], /*Q(31-mixing_matrix_e)*/
    Word16 mixing_matrix_e[CLDFB_NO_CHANNELS_MAX] )
{
@@ -367,10 +328,10 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
                }
                ELSE
                {
                    direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e)
                    direct_power_fx[w] = Mpy_32_16_1( ref_power_fx[bin_idx], hParamIsmDec->power_ratios_fx[band_idx][0][w] ); // Q(31-ref_power_e[bin_idx])
                    move32();
                }
                direct_power_e = ref_power_e;
                direct_power_e = ref_power_e[bin_idx];
                move16();
                IF( direct_power_fx[w] != 0 )
                {
@@ -409,8 +370,20 @@ static void ivas_param_ism_compute_mixing_matrix_fx(
                move32();
            }

            /* equal cx diag exponents */
            Word16 max_exp_cx_diag = cx_diag_e[bin_idx][0];
            Word32 cx_diag_eq_exp_fx[PARAM_ISM_MAX_DMX];
            FOR( i = 1; i < PARAM_ISM_MAX_DMX; i++ )
            {
                max_exp_cx_diag = s_max( max_exp_cx_diag, cx_diag_e[bin_idx][i] );
            }
            FOR( i = 0; i < PARAM_ISM_MAX_DMX; i++ )
            {
                cx_diag_eq_exp_fx[i] = L_shr_r( cx_diag_fx[bin_idx][i], sub( max_exp_cx_diag, cx_diag_e[bin_idx][i] ) ); // Q(31-max_exp_cx_diag)
            }

            /* Compute mixing matrix */
            computeMixingMatricesISM_fx( nchan_transport, num_wave, nchan_out_woLFE, response_matrix_fx, response_matrix_e, direct_power_fx, direct_power_e, cx_diag_fx[bin_idx], cx_diag_e, cy_diag_fx, cy_diag_e, proto_matrix_fx, 1,
            computeMixingMatricesISM_fx( nchan_transport, num_wave, nchan_out_woLFE, response_matrix_fx, response_matrix_e, direct_power_fx, direct_power_e, cx_diag_eq_exp_fx, max_exp_cx_diag, cy_diag_fx, cy_diag_e, proto_matrix_fx, 1,
                                         PARAM_MC_REG_SX_FX, PARAM_MC_REG_GHAT_FX, mixing_matrix_fx[bin_idx], &mixing_matrix_e[bin_idx] );
        }
    }
@@ -1070,7 +1043,6 @@ void ivas_param_ism_dec_digest_tc_fx(
    Word32 *transport_channels[], /* i  : synthesized core-coder transport channels/DirAC output  q_tc_in*/
    Word16 q_tc_in )
{
    Word16 exp_ref_power = 31, exp_cx_diag = 31;
    Word16 exp_real_tmp = 0, exp_imag_tmp = 0;
    move16();
    move16();
@@ -1078,6 +1050,9 @@ void ivas_param_ism_dec_digest_tc_fx(
    move16();
    Word32 ref_power_fx[CLDFB_NO_CHANNELS_MAX];
    Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];
    Word16  exp_ref_power[CLDFB_NO_CHANNELS_MAX];
    Word16  exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX];

    Word16 q_tc = q_tc_in;
    move16();
    Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
@@ -1132,15 +1107,11 @@ void ivas_param_ism_dec_digest_tc_fx(
    ivas_dirac_dec_set_md_map_fx( st_ivas, nCldfbSlots );
    /* set buffers to zero */

    FOR( bin_idx = 0; bin_idx < CLDFB_NO_CHANNELS_MAX; bin_idx++ )
    {
        set_zero_fx( cx_diag_fx[bin_idx], PARAM_ISM_MAX_DMX );
    }
    exp_cx_diag = 0;
    move16();
    set_zero_fx(&cx_diag_fx[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX);
    set16_zero_fx(&exp_cx_diag[0][0], CLDFB_NO_CHANNELS_MAX * PARAM_ISM_MAX_DMX);

    set_zero_fx( ref_power_fx, CLDFB_NO_CHANNELS_MAX );
    exp_ref_power = 0;
    move16();
    set16_zero_fx(&exp_ref_power[0], CLDFB_NO_CHANNELS_MAX);

    /* Frame-level Processing */
    /* De-quantization */
@@ -1269,7 +1240,7 @@ void ivas_param_ism_dec_digest_tc_fx(
                                            &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[current_idx],
                                            exp_imag_tmp,
                                            ch,
                                            ref_power_fx, &exp_ref_power, cx_diag_fx, &exp_cx_diag );
                                            ref_power_fx, exp_ref_power, cx_diag_fx, exp_cx_diag );

            exp_real_tmp = add( exp_real_tmp, scale_factor_real );
            exp_imag_tmp = add( exp_imag_tmp, scale_factor_imag );