Commit 7081b10f authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

port FIX_835_PARAMMC_BUFFER_VALUES back to this branch

parent f318b817
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@
#endif
#define FIX_1135_EXT_RENDERER_HANDLES                   /* VA: issue 1135: Memory usage reduction in external renderer: Allocate only handles that are really needed. */
#define FIX_1166_TDREND_DIV0                            /* FhG,Eri: issue 1166: potential divide by zero in TD Renderer */
//#define FIX_835_PARAMMC_BUFFER_VALUES                   /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */
#define FIX_835_PARAMMC_BUFFER_VALUES                   /* FhG: BASOP issue 835: wide range of buffer values for cx in ParamMC */

/* #################### End BE switches ################################## */

+377 −247
Original line number Diff line number Diff line
@@ -86,7 +86,11 @@ static int16_t ivas_param_mc_uniform_decoder( float *seq, const int16_t sz_seq,

static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hDirAC, float *ild_q, float *icc_q, const int16_t param_band_index, const int16_t nY_int, const PARAM_MC_SYNTHESIS_CONF synth_conf, const int16_t nY, const int16_t nX, float *Cx_state, float *Cproto, float *Cy_state );

#ifdef FIX_835_PARAMMC_BUFFER_VALUES
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);
#else
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);
#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 );

@@ -1484,12 +1488,23 @@ void ivas_param_mc_dec_prepare_renderer(
{
    PARAM_MC_DEC_HANDLE hParamMC;
    int16_t i;
#ifdef FIX_835_PARAMMC_BUFFER_VALUES
	int16_t is_next_band, skip_next_band;
#endif
    int16_t slot_idx, param_band_idx;
    int16_t nchan_transport, nchan_out_transport, nchan_out_cldfb;
    int16_t nchan_out_cov;
    /*CLDFB*/
#ifdef FIX_835_PARAMMC_BUFFER_VALUES
	float *pCx, *pCx_imag;
	float cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
	float cx_imag[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
	float cx_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
	float cx_imag_next_band[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
#else
	float cx[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
	float cx_imag[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
#endif
    float real_part, imag_part;
    /* format converter */
    int16_t channel_active[MAX_OUTPUT_CHANNELS];
@@ -1547,6 +1562,96 @@ void ivas_param_mc_dec_prepare_renderer(

    ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator );

#ifdef FIX_835_PARAMMC_BUFFER_VALUES
	/* loop over two bands at a time */
	for (param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2)
	{
		/* don't process next band if it exceeds the limit */
		skip_next_band = ((param_band_idx + 1) == hParamMC->num_param_bands_synth) ? 1 : 0;

		set_zero(cx, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS);
		set_zero(cx_imag, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS);
		set_zero(cx_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS);
		set_zero(cx_imag_next_band, PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS);

		/* slot loop for gathering the input data */
		for (slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++)
		{
			if (slot_idx >= 2 * hParamMC->hMetadataPMC->attackIndex)
			{
				for (is_next_band = 0; is_next_band < 2; is_next_band++)
				{
					if (is_next_band && skip_next_band)
					{
						continue;
					}

					ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot(&hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport],
						&hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport],
						is_next_band ? cx_next_band : cx,
						is_next_band ? cx_imag_next_band : cx_imag,
						param_band_idx + is_next_band,
						hParamMC,
						nchan_transport
					);
				}
			}
		}

		for (is_next_band = 0; is_next_band < 2; is_next_band++)
		{
			if (is_next_band && skip_next_band)
			{
				continue;
			}

			pCx = is_next_band ? &cx_next_band[0] : &cx[0];
			pCx_imag = is_next_band ? &cx_imag_next_band[0] : &cx_imag[0];

			for (i = 0; i < nchan_transport * nchan_transport; i++)
			{
				real_part = pCx[i];
				imag_part = pCx_imag[i];

				if (param_band_idx < hParamMC->max_param_band_abs_cov)
				{
					pCx[i] = sqrtf(real_part * real_part + imag_part * imag_part);
				}
				else
				{
					pCx[i] = real_part;
				}
			}
		}


		if (hParamMC->hMetadataPMC->bAttackPresent && (hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO))
		{
			v_add(cx, cx_next_band, cx, nchan_transport * nchan_transport);
			mvr2r(cx, cx_next_band, nchan_transport * nchan_transport);
		}

		for (is_next_band = 0; is_next_band < 2; is_next_band++)
		{
			if (is_next_band && skip_next_band)
			{
				continue;
			}

			/* generate mixing matrices */
			ivas_param_mc_get_mixing_matrices(hParamMC,
				hSynthesisOutputSetup,
				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,
				hParamMC->synthesis_conf,
				nchan_transport,
				nchan_out_cov);
		}
	}
#else
	for (param_band_idx = 0; param_band_idx < PARAM_MC_MAX_PARAMETER_BANDS; param_band_idx++)
	{
		set_zero(cx[param_band_idx], PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS);
@@ -1596,6 +1701,7 @@ void ivas_param_mc_dec_prepare_renderer(

    /* 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 );
#endif

    pop_wmops();

@@ -2277,6 +2383,18 @@ static void remove_lfe_from_cy(
 *------------------------------------------------------------------------*/

static void ivas_param_mc_get_mixing_matrices(
#ifdef FIX_835_PARAMMC_BUFFER_VALUES
	PARAM_MC_DEC_HANDLE hParamMC, /* i  : Parametric MC handle */
	IVAS_OUTPUT_SETUP *hSynthesisOutputSetup,
	float Cx_in[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i  : input 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 in the transported format     */
	const PARAM_MC_SYNTHESIS_CONF synth_config,                               /* i  : Parametric MC synthesis config                   */
	const int16_t nX,                                                         /* i  : number of transport channels                     */
	const int16_t nY_cov                                                      /* i  : number of covariance synthesis output channels   */
#else
	PARAM_MC_DEC_HANDLE hParamMC, /* i  : Parametric MC handle */
	IVAS_OUTPUT_SETUP *hSynthesisOutputSetup,
	float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i  : input covariance for all parameter bands         */
@@ -2286,9 +2404,12 @@ static void ivas_param_mc_get_mixing_matrices(
	const PARAM_MC_SYNTHESIS_CONF synth_config,                                                             /* i  : Parametric MC synthesis config                   */
	const int16_t nX,                                                                                       /* i  : number of transport channels                     */
	const int16_t nY_cov                                                                                    /* i  : number of covariance synthesis output channels   */
#endif
)
{
#ifndef FIX_835_PARAMMC_BUFFER_VALUES
	int16_t param_band_idx;
#endif
	float Cx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];
	float Cy[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
	float Cy_diag[MAX_CICP_CHANNELS];
@@ -2358,8 +2479,10 @@ static void ivas_param_mc_get_mixing_matrices(
		num_lfe_bands = PARAM_MC_MAX_BAND_LFE;
	}

#ifndef FIX_835_PARAMMC_BUFFER_VALUES
	for (param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx++)
	{
#endif
		if (hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands)
		{
			remove_lfe = 1;
@@ -2374,7 +2497,11 @@ static void ivas_param_mc_get_mixing_matrices(
		brange[0] = hParamMC->band_grouping[param_band_idx];
		brange[1] = hParamMC->band_grouping[param_band_idx + 1];

#ifdef FIX_835_PARAMMC_BUFFER_VALUES
		Cx_state = Cx_in;
#else
		Cx_state = Cx_in[param_band_idx];
#endif
		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];

@@ -2518,12 +2645,15 @@ static void ivas_param_mc_get_mixing_matrices(
		{
			mvr2r(mixing_matrix_local, mixing_matrix[param_band_idx], nY_cov * nX);
		}
#ifndef FIX_835_PARAMMC_BUFFER_VALUES
	}
#endif

	return;
}



/*-------------------------------------------------------------------------
 * param_mc_update_mixing_matrices()
 *