Commit 4254c638 authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

[cleanup] accept FIX_1024_REMOVE_PARAMMC_MIXING_MAT

parent dbf1b002
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -189,7 +189,6 @@

#define FIX_777_COMBI_RENDER_CONFIG_FILE                /* Philips: Fix for combined renderer config file support */
#define NONBE_FIX_991_PARAMBIN_BINARY_HRTF              /* Nokia: issue #991: fix using of binary file HRTF in ParamBin (to actiate when USE_NEW_HRTF_BINARY_FILE_FORMAT and FIX_777_COMBI_RENDER_CONFIG_FILE are on  )*/
#define FIX_1024_REMOVE_PARAMMC_MIXING_MAT              /* VA: issue 1024: remove unused function ivas_param_mc_get_mono_stereo_mixing_matrices() */
#define FIX_1023_REMOVE_PARAMMC_DEC                     /* VA: issue 1023: remove unused function ivas_param_mc_dec() */
#define NONBE_FIX_1034_DRY_MASA_RATIOS                  /* Nokia: Fix issue 1034, use of wrong numDir state. */
#define NONBE_FIX_1021_ISM_BRIR_RS_FLUSH                /* FhG: issue #1021: fix ISM with JBM and RS renderer flushing*/
+0 −143
Original line number Diff line number Diff line
@@ -88,10 +88,6 @@ static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hDirAC, float *ild

static void ivas_param_mc_get_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t param_band_idx, float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nX, const int16_t nY );

#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT
static void ivas_param_mc_get_mono_stereo_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t param_band_idx, float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_intern, const int16_t nX, const int16_t nY_cov );

#endif
static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY );

static void ivas_param_mc_dec_compute_interpolator( const uint16_t bAttackPresent, const uint16_t attackPos, const uint16_t interp_length, float *interpolator );
@@ -1496,21 +1492,6 @@ void ivas_param_mc_dec_digest_tc(
                continue;
            }

#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT
            if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO )
            {
                ivas_param_mc_get_mono_stereo_mixing_matrices( hParamMC,
                                                               is_next_band ? cx_next_band : cx,
                                                               param_band_idx + is_next_band,
                                                               hParamMC->h_output_synthesis_cov_state.mixing_matrix,
                                                               hParamMC->h_output_synthesis_cov_state.mixing_matrix_res,
                                                               nchan_out_transport,
                                                               nchan_transport,
                                                               nchan_out_cov );
            }
            else
            {
#endif
                /* generate mixing matrices */
                ivas_param_mc_get_mixing_matrices( hParamMC,
                                                   hSynthesisOutputSetup,
@@ -1522,9 +1503,6 @@ void ivas_param_mc_dec_digest_tc(
                                                   hParamMC->synthesis_conf,
                                                   nchan_transport,
                                                   nchan_out_cov );
#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT
            }
#endif
        }
    }

@@ -2496,127 +2474,6 @@ static void ivas_param_mc_get_mixing_matrices(
}


#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT
/*-------------------------------------------------------------------------
 * ivas_param_mc_get_mono_stereo_mixing_matrices()
 *
 * calculate the direct and residual mixing matrices
 * for mono and stereo output
 *------------------------------------------------------------------------*/

static void ivas_param_mc_get_mono_stereo_mixing_matrices(
    PARAM_MC_DEC_HANDLE hParamMC,                                             /* i  : Parametric MC handle                                  */
    float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i  : transport channel covariance for all parameter bands  */
    const int16_t param_band_idx,                                             /* i  : parameter band index                                  */
    float *mixing_matrix[],                                                   /* o  : direct mixing matrices for all parameter bands        */
    float *mixing_matrix_res[],                                               /* o  : residual mixing matrices for all parameter bands      */
    const int16_t nY_intern,                                                  /* i  : number of channels of the transport format            */
    const int16_t nX,                                                         /* i  : number of transport channels                          */
    const int16_t nY_cov                                                      /* i  : number of output channels                             */
)
{
    float Cy_full[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
    float mixing_matrix_woLFE[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
    float Nrqq[MAX_OUTPUT_CHANNELS];
    float target_ch_ener[MAX_OUTPUT_CHANNELS];
    int16_t k, l;
    float *ild_q;

    float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
    float Cy_diag[MAX_CICP_CHANNELS];
    float Cproto_diag[MAX_CICP_CHANNELS];
    float Cproto[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
    float mat_mult_buffer1[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
    float *Cx_state;
    float *Cx_old_state;
    float Cy_state[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
    float *Cy_old_state;
    int16_t nY_band;
    float proto_matrix[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS];
    uint16_t i;

    set_zero( Cproto, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS );
    set_zero( mat_mult_buffer1, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS );
    set_zero( proto_matrix, PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS );

    mvr2r( hParamMC->h_output_synthesis_params.proto_matrix, proto_matrix, nY_cov * nX );
    nY_band = nY_cov;

    Cx_state = Cx_in;
    Cx_old_state = hParamMC->h_output_synthesis_cov_state.cx_old[param_band_idx];
    Cy_old_state = hParamMC->h_output_synthesis_cov_state.cy_old[param_band_idx];
    set_zero( Nrqq, MAX_OUTPUT_CHANNELS );
    set_zero( target_ch_ener, MAX_OUTPUT_CHANNELS );
    set_zero( Cy_full, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS );
    set_zero( Cy_state, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS );
    set_zero( Cproto_diag, MAX_CICP_CHANNELS );
    ild_q = hParamMC->icld_q + param_band_idx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe;

    /*get back Nrg*/
    for ( k = 0; k < nY_intern; k++ )
    {
        float ref_ener = 0.0f;
        int16_t ref_channel_cnt;
        int16_t ref_channel_idx;

        for ( ref_channel_cnt = 0; ref_channel_cnt < hParamMC->hMetadataPMC->ild_mapping_conf->num_ref_channels[k]; ref_channel_cnt++ )
        {
            ref_channel_idx = hParamMC->hMetadataPMC->ild_mapping_conf->ref_channel_idx[k][ref_channel_cnt];
            ref_ener += Cx_state[ref_channel_idx + ref_channel_idx * nX];
        }
        Nrqq[hParamMC->hMetadataPMC->ild_mapping_conf->ild_index[k]] = powf( 10.0f, ild_q[k] / 10.0f ) * hParamMC->hMetadataPMC->ild_factors[k] * ref_ener;
    }
    for ( k = 0; k < nY_cov; k++ )
    {
        for ( l = 0; l < nY_intern; l++ )
        {
            target_ch_ener[k] += hParamMC->ls_conv_dmx_matrix[k + l * nY_cov] * Nrqq[l];
        }
        Cy_state[k + nY_cov * k] = target_ch_ener[k];
    }

    /* Smoothing: Sum over two buffers */
    if ( hParamMC->hMetadataPMC->bAttackPresent )
    {
        /* no smoothing on attacks */
        mvr2r( Cx_state, Cx, nX * nX );
        mvr2r( Cy_state, Cy_full, nY_cov * nY_cov );
    }
    else
    {
        /* smoothing gains are now identical to one, simply add up */
        v_add( Cx_state, Cx_old_state, Cx, nX * nX );
        v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov );
    }

    /* cov buffer update */
    mvr2r( Cx_state, Cx_old_state, nX * nX );
    mvr2r( Cy_state, Cy_old_state, nY_cov * nY_cov );


    matrix_product( proto_matrix, nY_band, nX, 0, Cx, nX, nX, 0, mat_mult_buffer1 );

    matrix_product_diag( mat_mult_buffer1, nY_band, nX, 0, proto_matrix, nY_band, nX, 1, Cproto_diag );

    /* Computing the mixing matrices */
    for ( i = 0; i < nY_band; i++ )
    {
        Cy_diag[i] = Cy_full[i + nY_band * i];
        Cy_diag[i] = sqrtf( Cy_diag[i] / ( Cproto_diag[i] + EPSILON ) );
    }

    diag_matrix_product( Cy_diag, nY_band, proto_matrix, nY_band, nX, 0, mixing_matrix_woLFE );

    mvr2r( mixing_matrix_woLFE, mixing_matrix[param_band_idx], nY_cov * nX );
    if ( hParamMC->band_grouping[param_band_idx] < hParamMC->h_output_synthesis_params.max_band_decorr )
    {
        set_zero( mixing_matrix_res[param_band_idx], nY_cov * nY_cov );
    }

    return;
}

#endif

/*-------------------------------------------------------------------------
 * param_mc_update_mixing_matrices()
+0 −8
Original line number Diff line number Diff line
@@ -973,11 +973,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
        set_zero( Nrqq, MAX_OUTPUT_CHANNELS );
        set_zero( target_ch_ener, MAX_OUTPUT_CHANNELS );

#ifdef FIX_1024_REMOVE_PARAMMC_MIXING_MAT
        /* Step 1.2, get target channel energies for the transported format, Nrqq calculation */
#else
        /* Step 1.2, get target channel energies for the transported format as in ivas_param_mc_get_mono_stereo_mixing_matrices(), Nrqq calculation */
#endif
        ild_q = hParamMC->icld_q + bandIdx * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe;

        for ( chInIdx = 0; chInIdx < nchan_transport_format; chInIdx++ )
@@ -995,11 +991,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc(
            Nrqq[hParamMC->hMetadataPMC->ild_mapping_conf->ild_index[chInIdx]] = powf( 10.0f, ild_q[chInIdx] / 10.0f ) * hParamMC->hMetadataPMC->ild_factors[chInIdx] * ref_ener;
        }

#ifdef FIX_1024_REMOVE_PARAMMC_MIXING_MAT
        /* Step 1.3 get target Cy (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */
#else
        /* Step 1.3 get target Cy like in ivas_param_mc_get_mono_stereo_mixing_matrices() (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */
#endif
        for ( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ )
        {
            for ( i = 0; i < nchan_transport_format; i++ )