Commit a1b756c4 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_1024_REMOVE_PARAMMC_MIXING_MAT

parent eab00917
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -156,7 +156,6 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
/*#define SPLIT_REND_WITH_HEAD_ROT  */                  /* Dlb,FhG: Split Rendering contributions 21 and 35 */

#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 FIX_1022_REMOVE_PARAMISM_DEC                    /* VA: issue 1022: remove unused function ivas_param_ism_dec() */
#define FIX_1033_MEMORY_LEAK_OMASA                      /* Nokia / Orange: issue #1033: Memory leak in OMASA to BINAURAL with HRTF with bitrate switching */
+0 −137
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_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], 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_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], 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 );
@@ -1456,19 +1452,8 @@ void ivas_param_mc_dec_digest_tc(
    }


#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, cx, 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, cx, hParamMC->h_output_synthesis_cov_state.mixing_matrix, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
#ifndef FIX_1024_REMOVE_PARAMMC_MIXING_MAT
    }
#endif

    pop_wmops();

@@ -2454,128 +2439,6 @@ static void ivas_param_mc_get_mixing_matrices(
    return;
}

#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_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i  : transport channel covariance for all parameter bands  */
    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                             */
{
    int16_t param_band_idx;
    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;

    for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++ )
    {
        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;

        Cx_state = Cx_in[param_band_idx];
        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++ )