Loading lib_enc/ivas_mc_param_enc.c +71 −71 Original line number Diff line number Diff line Loading @@ -56,16 +56,16 @@ static void ivas_param_mc_dmx( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float data_dmx[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float Cy_real[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_real[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_parameter_quantizer( const float *x, const int16_t L, const int16_t sz_quantizer, const float *quantizer, int16_t *quant_idx, float *y ); static void ivas_param_mc_transient_detection( PARAM_MC_ENC_HANDLE hParamMC, TRAN_DET_HANDLE hTranDet, int16_t *bAttackPresent, int16_t *attackIdx ); static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], const int16_t freq_idx, const int16_t nchan_input, int16_t *ICC_idx_out ); static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], const int16_t freq_idx, const int16_t nchan_input, int16_t *ICC_idx_out ); static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t freq_idx, const int16_t nchan_input, const int16_t nchan_transport, int16_t *ILD_idx_out, float ILD_q[PARAM_MC_SZ_ILD_MAP] ); static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_real[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t freq_idx, const int16_t nchan_input, const int16_t nchan_transport, int16_t *ILD_idx_out, float ILD_q[PARAM_MC_SZ_ILD_MAP] ); static void ivas_param_mc_write_bs( const PARAM_MC_ENC_HANDLE hParamMC, int16_t *ILD_idx, int16_t *ICC_idx, uint16_t bit_buffer[PARAM_MC_MAX_BITS], int16_t *bit_pos ); Loading Loading @@ -350,8 +350,8 @@ void ivas_param_mc_enc( ) { int16_t k; float Cy_sum[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_sum[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float Cy_real[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_real[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float ILD_q[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP]; int16_t ILD_idx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_SZ_ILD_MAP]; int16_t ICC_idx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_SZ_ICC_MAP]; Loading @@ -376,11 +376,11 @@ void ivas_param_mc_enc( { for ( ch = 0; ch < MAX_CICP_CHANNELS; ch++ ) { set_zero( Cy_sum[band][ch], MAX_CICP_CHANNELS ); set_zero( Cy_real[band][ch], MAX_CICP_CHANNELS ); } for ( ch = 0; ch < PARAM_MC_MAX_TRANSPORT_CHANS; ch++ ) { set_zero( Cx_sum[band][ch], PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( Cx_real[band][ch], PARAM_MC_MAX_TRANSPORT_CHANS ); } } Loading Loading @@ -449,7 +449,7 @@ void ivas_param_mc_enc( /* Encoding */ /* parameter estimation*/ ivas_param_mc_param_est_enc( hParamMC, data_f, Cy_sum, Cx_sum, input_frame, nchan_inp, st_ivas->nchan_transport ); ivas_param_mc_param_est_enc( hParamMC, data_f, Cy_real, Cx_real, input_frame, nchan_inp, st_ivas->nchan_transport ); band_step = hParamMC->hMetadataPMC.bAttackPresent ? PARAM_MC_TRANSIENT_BAND_STEP : 1; Loading @@ -457,13 +457,13 @@ void ivas_param_mc_enc( /* ILD parameter quantization */ for ( k = 0; k < hParamMC->hMetadataPMC.nbands_coded; k += band_step ) { ivas_param_mc_quantize_ilds( hParamMC, Cy_sum[k], Cx_sum[k], k, nchan_inp, st_ivas->nchan_transport, ILD_idx, ILD_q[k] ); ivas_param_mc_quantize_ilds( hParamMC, Cy_real[k], Cx_real[k], k, nchan_inp, st_ivas->nchan_transport, ILD_idx, ILD_q[k] ); } /* ICC parameter quantization */ for ( k = 0; k < hParamMC->hMetadataPMC.nbands_coded; k += band_step ) { ivas_param_mc_quantize_iccs( hParamMC, Cy_sum[k], k, nchan_inp, ICC_idx ); ivas_param_mc_quantize_iccs( hParamMC, Cy_real[k], k, nchan_inp, ICC_idx ); } /* time domain DMX generation*/ Loading Loading @@ -556,8 +556,8 @@ static void ivas_param_mc_dmx( static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ float *data_f[], /* i : Input frame in the time domain */ float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */ float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */ float Cy_real[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */ float Cx_real[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */ const int16_t input_frame, /* i : Input frame length */ const int16_t nchan_input, /* i : number of input channels */ const int16_t nchan_transport /* i : number of transport channels */ Loading @@ -581,8 +581,8 @@ static void ivas_param_mc_param_est_enc( float dmx_real[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Real Part */ float dmx_imag[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Imag Part */ float a, b, c, d; /* Tmp complex values */ float Cy_sum_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_sum_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float Cy_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float real_part, imag_part; int16_t start_ts; const float *p_dmx_fac; Loading @@ -600,12 +600,12 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) { set_zero( Cy_sum_imag[cur_param_band][ch_idx1], MAX_CICP_CHANNELS ); set_zero( Cy_imag[cur_param_band][ch_idx1], MAX_CICP_CHANNELS ); } for ( ch_idx1 = 0; ch_idx1 < PARAM_MC_MAX_TRANSPORT_CHANS; ch_idx1++ ) { set_zero( Cx_sum_imag[cur_param_band][ch_idx1], PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( Cx_imag[cur_param_band][ch_idx1], PARAM_MC_MAX_TRANSPORT_CHANS ); } } Loading Loading @@ -672,8 +672,8 @@ static void ivas_param_mc_param_est_enc( d = dmx_imag[ch_idx2]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cx_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cx_sum_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; Cx_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cx_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; } } Loading @@ -688,8 +688,8 @@ static void ivas_param_mc_param_est_enc( d = slot_frame_f_imag[ch_idx2][cur_cldfb_band]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cy_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; Cy_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cy_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; } } } Loading Loading @@ -730,7 +730,7 @@ static void ivas_param_mc_param_est_enc( d = dmx_imag[ch_idx2]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cx_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cx_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; } } Loading @@ -745,7 +745,7 @@ static void ivas_param_mc_param_est_enc( d = slot_frame_f_imag[ch_idx2][cur_cldfb_band]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cy_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cy_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; } } } Loading @@ -760,10 +760,10 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { Cy_sum[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_sum_imag[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum_imag[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_real[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_real[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_imag[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_imag[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; } } Loading @@ -771,8 +771,8 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { Cy_sum[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_real[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_real[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; } } } Loading Loading @@ -805,7 +805,7 @@ static void ivas_param_mc_param_est_enc( /* get ICLDs */ for ( k = 0; k < nchan_input; ++k ) { Nrg[k] = Cy_sum[cur_param_band][k][k]; Nrg[k] = Cy_real[cur_param_band][k][k]; } for ( k = 0; k < num_ilds_to_code; ++k ) { Loading @@ -816,7 +816,7 @@ static void ivas_param_mc_param_est_enc( for ( ref_channel_cnt = 0; ref_channel_cnt < h_ild_mapping->num_ref_channels[k]; ref_channel_cnt++ ) { ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt]; ref_ener += Cx_sum[cur_param_band][ref_channel_idx][ref_channel_idx]; ref_ener += Cx_real[cur_param_band][ref_channel_idx][ref_channel_idx]; } ILD[k] = 10.0f * log10f( ( Nrg[h_ild_mapping->ild_index[k]] + EPSILON ) / ( hParamMC->hMetadataPMC.ild_factors[k] * ref_ener + EPSILON ) ); if ( hParamMC->prev_ilds[cur_param_band][k] - ILD[k] > param_mc_ild_diff_threshold[cur_param_band] ) Loading @@ -843,8 +843,8 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) { Cx_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_sum[cur_param_band][ch_idx1][ch_idx2]; Cx_sum_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_sum_imag[cur_param_band][ch_idx1][ch_idx2]; Cx_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_real[cur_param_band][ch_idx1][ch_idx2]; Cx_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_imag[cur_param_band][ch_idx1][ch_idx2]; } } Loading @@ -852,8 +852,8 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { Cy_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum[cur_param_band][ch_idx1][ch_idx2]; Cy_sum_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2]; Cy_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_real[cur_param_band][ch_idx1][ch_idx2]; Cy_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_imag[cur_param_band][ch_idx1][ch_idx2]; } } } Loading @@ -866,7 +866,7 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) { Cx_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_sum[cur_param_band][ch_idx1][ch_idx2]; Cx_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_real[cur_param_band][ch_idx1][ch_idx2]; } } Loading @@ -874,7 +874,7 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { Cy_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum[cur_param_band][ch_idx1][ch_idx2]; Cy_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_real[cur_param_band][ch_idx1][ch_idx2]; } } } Loading @@ -892,11 +892,11 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = 0; ch_idx2 < nchan_transport; ch_idx2++ ) { real_part = Cx_sum[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cx_sum_imag[cur_param_band][ch_idx1][ch_idx2]; real_part = Cx_real[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cx_imag[cur_param_band][ch_idx1][ch_idx2]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cx_sum[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); Cx_real[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); } } Loading @@ -905,14 +905,14 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ch_idx2++ ) { real_part = Cy_sum[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2]; Cy_sum[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); real_part = Cy_real[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cy_imag[cur_param_band][ch_idx1][ch_idx2]; Cy_real[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); } } } if ( Cy_sum[0][LFE_CHANNEL][LFE_CHANNEL] < PARAM_MC_LFE_ON_THRESH ) if ( Cy_real[0][LFE_CHANNEL][LFE_CHANNEL] < PARAM_MC_LFE_ON_THRESH ) { hParamMC->hMetadataPMC.lfe_on = 0; } Loading @@ -935,8 +935,8 @@ static void ivas_param_mc_param_est_enc( static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* i : Covariance matrix of the dmx */ float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ float Cx_real[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* i : Covariance matrix of the dmx */ const int16_t freq_idx, /* i : frequency index being processed */ const int16_t nchan_input, /* i : number of input channels */ const int16_t nchan_transport, /* i : number of transport channels */ Loading Loading @@ -984,7 +984,7 @@ static void ivas_param_mc_quantize_ilds( /* get ICLDs */ for ( k = 0; k < Ny; ++k ) { Nrg[k] = Cy[k][k]; Nrg[k] = Cy_real[k][k]; } /* limit ILDs if DMX energy is lower than sum of channel energies */ Loading @@ -1001,7 +1001,7 @@ static void ivas_param_mc_quantize_ilds( for ( k = 0; k < nchan_transport; k++ ) { dmx_ener += Cx[k][k]; dmx_ener += Cx_real[k][k]; } ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); Loading @@ -1026,7 +1026,7 @@ static void ivas_param_mc_quantize_ilds( for ( k = 0; k < nchan_transport; k++ ) { dmx_ener += Cx[k][k]; dmx_ener += Cx_real[k][k]; } ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); Loading Loading @@ -1057,7 +1057,7 @@ static void ivas_param_mc_quantize_ilds( for ( ref_channel_cnt = 0; ref_channel_cnt < h_ild_mapping->num_ref_channels[k]; ref_channel_cnt++ ) { ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt]; ref_ener += Cx[ref_channel_idx][ref_channel_idx]; ref_ener += Cx_real[ref_channel_idx][ref_channel_idx]; } ILD[k] = 10.0f * log10f( ( Nrg[h_ild_mapping->ild_index[k]] + EPSILON ) / ( hParamMC->hMetadataPMC.ild_factors[k] * ref_ener + EPSILON ) ); hParamMC->prev_ilds[freq_idx][k] = ILD[k]; Loading Loading @@ -1088,7 +1088,7 @@ static void ivas_param_mc_quantize_ilds( static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ const int16_t freq_idx, /* i : frequency index being processed */ const int16_t nchan_input, /* i : number of input channels */ int16_t *ICC_idx_out /* o : quantizer indices */ Loading Loading @@ -1129,17 +1129,17 @@ static void ivas_param_mc_quantize_iccs( /* Get ICC matrix from Cy */ for ( k = 0; k < Ny; ++k ) { Nrg[k] = Cy[k][k]; Nrg[k] = Cy_real[k][k]; a = 1.0f / ( sqrtf( Nrg[k] ) + EPSILON ); for ( i = k; i < Ny; ++i ) { Cy[k][i] = Cy[k][i] * a; Cy_real[k][i] = Cy_real[k][i] * a; } for ( i = 0; i <= k; i++ ) { Cy[i][k] = Cy[i][k] * a; Cy_real[i][k] = Cy_real[i][k] * a; } } Loading @@ -1150,12 +1150,12 @@ static void ivas_param_mc_quantize_iccs( { for ( i = k; i < Ny; ++i ) { Cy[k][i] = 1.0f; Cy_real[k][i] = 1.0f; } for ( i = 0; i <= k; ++i ) { Cy[i][k] = 1.0f; Cy_real[i][k] = 1.0f; } } } Loading @@ -1165,7 +1165,7 @@ static void ivas_param_mc_quantize_iccs( { tmp_map[0] = hParamMC->hMetadataPMC.icc_mapping_conf->icc_mapping[k][0]; tmp_map[1] = hParamMC->hMetadataPMC.icc_mapping_conf->icc_mapping[k][1]; ICC_vect[k] = Cy[tmp_map[0]][tmp_map[1]]; ICC_vect[k] = Cy_real[tmp_map[0]][tmp_map[1]]; } /* Quantization */ Loading Loading
lib_enc/ivas_mc_param_enc.c +71 −71 Original line number Diff line number Diff line Loading @@ -56,16 +56,16 @@ static void ivas_param_mc_dmx( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float data_dmx[][L_FRAME48k], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, float *data_f[], float Cy_real[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_real[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t input_frame, const int16_t nchan_input, const int16_t nchan_transport ); static void ivas_param_mc_parameter_quantizer( const float *x, const int16_t L, const int16_t sz_quantizer, const float *quantizer, int16_t *quant_idx, float *y ); static void ivas_param_mc_transient_detection( PARAM_MC_ENC_HANDLE hParamMC, TRAN_DET_HANDLE hTranDet, int16_t *bAttackPresent, int16_t *attackIdx ); static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], const int16_t freq_idx, const int16_t nchan_input, int16_t *ICC_idx_out ); static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], const int16_t freq_idx, const int16_t nchan_input, int16_t *ICC_idx_out ); static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t freq_idx, const int16_t nchan_input, const int16_t nchan_transport, int16_t *ILD_idx_out, float ILD_q[PARAM_MC_SZ_ILD_MAP] ); static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], float Cx_real[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], const int16_t freq_idx, const int16_t nchan_input, const int16_t nchan_transport, int16_t *ILD_idx_out, float ILD_q[PARAM_MC_SZ_ILD_MAP] ); static void ivas_param_mc_write_bs( const PARAM_MC_ENC_HANDLE hParamMC, int16_t *ILD_idx, int16_t *ICC_idx, uint16_t bit_buffer[PARAM_MC_MAX_BITS], int16_t *bit_pos ); Loading Loading @@ -350,8 +350,8 @@ void ivas_param_mc_enc( ) { int16_t k; float Cy_sum[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_sum[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float Cy_real[PARAM_MC_MAX_PARAMETER_BANDS][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_real[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float ILD_q[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_SZ_ILD_MAP]; int16_t ILD_idx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_SZ_ILD_MAP]; int16_t ICC_idx[PARAM_MC_MAX_PARAMETER_BANDS * PARAM_MC_SZ_ICC_MAP]; Loading @@ -376,11 +376,11 @@ void ivas_param_mc_enc( { for ( ch = 0; ch < MAX_CICP_CHANNELS; ch++ ) { set_zero( Cy_sum[band][ch], MAX_CICP_CHANNELS ); set_zero( Cy_real[band][ch], MAX_CICP_CHANNELS ); } for ( ch = 0; ch < PARAM_MC_MAX_TRANSPORT_CHANS; ch++ ) { set_zero( Cx_sum[band][ch], PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( Cx_real[band][ch], PARAM_MC_MAX_TRANSPORT_CHANS ); } } Loading Loading @@ -449,7 +449,7 @@ void ivas_param_mc_enc( /* Encoding */ /* parameter estimation*/ ivas_param_mc_param_est_enc( hParamMC, data_f, Cy_sum, Cx_sum, input_frame, nchan_inp, st_ivas->nchan_transport ); ivas_param_mc_param_est_enc( hParamMC, data_f, Cy_real, Cx_real, input_frame, nchan_inp, st_ivas->nchan_transport ); band_step = hParamMC->hMetadataPMC.bAttackPresent ? PARAM_MC_TRANSIENT_BAND_STEP : 1; Loading @@ -457,13 +457,13 @@ void ivas_param_mc_enc( /* ILD parameter quantization */ for ( k = 0; k < hParamMC->hMetadataPMC.nbands_coded; k += band_step ) { ivas_param_mc_quantize_ilds( hParamMC, Cy_sum[k], Cx_sum[k], k, nchan_inp, st_ivas->nchan_transport, ILD_idx, ILD_q[k] ); ivas_param_mc_quantize_ilds( hParamMC, Cy_real[k], Cx_real[k], k, nchan_inp, st_ivas->nchan_transport, ILD_idx, ILD_q[k] ); } /* ICC parameter quantization */ for ( k = 0; k < hParamMC->hMetadataPMC.nbands_coded; k += band_step ) { ivas_param_mc_quantize_iccs( hParamMC, Cy_sum[k], k, nchan_inp, ICC_idx ); ivas_param_mc_quantize_iccs( hParamMC, Cy_real[k], k, nchan_inp, ICC_idx ); } /* time domain DMX generation*/ Loading Loading @@ -556,8 +556,8 @@ static void ivas_param_mc_dmx( static void ivas_param_mc_param_est_enc( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ float *data_f[], /* i : Input frame in the time domain */ float Cy_sum[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */ float Cx_sum[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */ float Cy_real[][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* o : Covariance matrix for the original frame */ float Cx_real[][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* o : Covariance matrix for the downmixed frame */ const int16_t input_frame, /* i : Input frame length */ const int16_t nchan_input, /* i : number of input channels */ const int16_t nchan_transport /* i : number of transport channels */ Loading @@ -581,8 +581,8 @@ static void ivas_param_mc_param_est_enc( float dmx_real[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Real Part */ float dmx_imag[PARAM_MC_MAX_TRANSPORT_CHANS]; /* Downmix channel - Imag Part */ float a, b, c, d; /* Tmp complex values */ float Cy_sum_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_sum_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float Cy_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][MAX_CICP_CHANNELS][MAX_CICP_CHANNELS]; float Cx_imag[PARAM_MC_MAX_PARAM_BAND_ABS_COV_ENC][PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS]; float real_part, imag_part; int16_t start_ts; const float *p_dmx_fac; Loading @@ -600,12 +600,12 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx1 = 0; ch_idx1 < MAX_CICP_CHANNELS; ch_idx1++ ) { set_zero( Cy_sum_imag[cur_param_band][ch_idx1], MAX_CICP_CHANNELS ); set_zero( Cy_imag[cur_param_band][ch_idx1], MAX_CICP_CHANNELS ); } for ( ch_idx1 = 0; ch_idx1 < PARAM_MC_MAX_TRANSPORT_CHANS; ch_idx1++ ) { set_zero( Cx_sum_imag[cur_param_band][ch_idx1], PARAM_MC_MAX_TRANSPORT_CHANS ); set_zero( Cx_imag[cur_param_band][ch_idx1], PARAM_MC_MAX_TRANSPORT_CHANS ); } } Loading Loading @@ -672,8 +672,8 @@ static void ivas_param_mc_param_est_enc( d = dmx_imag[ch_idx2]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cx_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cx_sum_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; Cx_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cx_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; } } Loading @@ -688,8 +688,8 @@ static void ivas_param_mc_param_est_enc( d = slot_frame_f_imag[ch_idx2][cur_cldfb_band]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cy_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; Cy_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cy_imag[cur_param_band][ch_idx1][ch_idx2] += a * d - b * c; } } } Loading Loading @@ -730,7 +730,7 @@ static void ivas_param_mc_param_est_enc( d = dmx_imag[ch_idx2]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cx_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cx_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; } } Loading @@ -745,7 +745,7 @@ static void ivas_param_mc_param_est_enc( d = slot_frame_f_imag[ch_idx2][cur_cldfb_band]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cy_sum[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; Cy_real[cur_param_band][ch_idx1][ch_idx2] += a * c + b * d; } } } Loading @@ -760,10 +760,10 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { Cy_sum[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_sum_imag[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum_imag[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_real[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_real[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_imag[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_imag[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; } } Loading @@ -771,8 +771,8 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx1 = 0; ch_idx1 < nchan_input; ++ch_idx1 ) { Cy_sum[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_sum[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; Cy_real[cur_param_band][hParamMC->lfe_index][ch_idx1] = 0.0f; Cy_real[cur_param_band][ch_idx1][hParamMC->lfe_index] = 0.0f; } } } Loading Loading @@ -805,7 +805,7 @@ static void ivas_param_mc_param_est_enc( /* get ICLDs */ for ( k = 0; k < nchan_input; ++k ) { Nrg[k] = Cy_sum[cur_param_band][k][k]; Nrg[k] = Cy_real[cur_param_band][k][k]; } for ( k = 0; k < num_ilds_to_code; ++k ) { Loading @@ -816,7 +816,7 @@ static void ivas_param_mc_param_est_enc( for ( ref_channel_cnt = 0; ref_channel_cnt < h_ild_mapping->num_ref_channels[k]; ref_channel_cnt++ ) { ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt]; ref_ener += Cx_sum[cur_param_band][ref_channel_idx][ref_channel_idx]; ref_ener += Cx_real[cur_param_band][ref_channel_idx][ref_channel_idx]; } ILD[k] = 10.0f * log10f( ( Nrg[h_ild_mapping->ild_index[k]] + EPSILON ) / ( hParamMC->hMetadataPMC.ild_factors[k] * ref_ener + EPSILON ) ); if ( hParamMC->prev_ilds[cur_param_band][k] - ILD[k] > param_mc_ild_diff_threshold[cur_param_band] ) Loading @@ -843,8 +843,8 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) { Cx_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_sum[cur_param_band][ch_idx1][ch_idx2]; Cx_sum_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_sum_imag[cur_param_band][ch_idx1][ch_idx2]; Cx_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_real[cur_param_band][ch_idx1][ch_idx2]; Cx_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_imag[cur_param_band][ch_idx1][ch_idx2]; } } Loading @@ -852,8 +852,8 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { Cy_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum[cur_param_band][ch_idx1][ch_idx2]; Cy_sum_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2]; Cy_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_real[cur_param_band][ch_idx1][ch_idx2]; Cy_imag[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_imag[cur_param_band][ch_idx1][ch_idx2]; } } } Loading @@ -866,7 +866,7 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = 0; ch_idx2 < nchan_transport; ++ch_idx2 ) { Cx_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_sum[cur_param_band][ch_idx1][ch_idx2]; Cx_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cx_real[cur_param_band][ch_idx1][ch_idx2]; } } Loading @@ -874,7 +874,7 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ++ch_idx2 ) { Cy_sum[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_sum[cur_param_band][ch_idx1][ch_idx2]; Cy_real[cur_param_band - 1][ch_idx1][ch_idx2] += Cy_real[cur_param_band][ch_idx1][ch_idx2]; } } } Loading @@ -892,11 +892,11 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = 0; ch_idx2 < nchan_transport; ch_idx2++ ) { real_part = Cx_sum[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cx_sum_imag[cur_param_band][ch_idx1][ch_idx2]; real_part = Cx_real[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cx_imag[cur_param_band][ch_idx1][ch_idx2]; /* (a-ib)(c+id) = ac + bd + i(ad-bc) */ Cx_sum[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); Cx_real[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); } } Loading @@ -905,14 +905,14 @@ static void ivas_param_mc_param_est_enc( { for ( ch_idx2 = ch_idx1; ch_idx2 < nchan_input; ch_idx2++ ) { real_part = Cy_sum[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cy_sum_imag[cur_param_band][ch_idx1][ch_idx2]; Cy_sum[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); real_part = Cy_real[cur_param_band][ch_idx1][ch_idx2]; imag_part = Cy_imag[cur_param_band][ch_idx1][ch_idx2]; Cy_real[cur_param_band][ch_idx1][ch_idx2] = sqrtf( real_part * real_part + imag_part * imag_part ); } } } if ( Cy_sum[0][LFE_CHANNEL][LFE_CHANNEL] < PARAM_MC_LFE_ON_THRESH ) if ( Cy_real[0][LFE_CHANNEL][LFE_CHANNEL] < PARAM_MC_LFE_ON_THRESH ) { hParamMC->hMetadataPMC.lfe_on = 0; } Loading @@ -935,8 +935,8 @@ static void ivas_param_mc_param_est_enc( static void ivas_param_mc_quantize_ilds( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ float Cx[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* i : Covariance matrix of the dmx */ float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ float Cx_real[PARAM_MC_MAX_TRANSPORT_CHANS][PARAM_MC_MAX_TRANSPORT_CHANS], /* i : Covariance matrix of the dmx */ const int16_t freq_idx, /* i : frequency index being processed */ const int16_t nchan_input, /* i : number of input channels */ const int16_t nchan_transport, /* i : number of transport channels */ Loading Loading @@ -984,7 +984,7 @@ static void ivas_param_mc_quantize_ilds( /* get ICLDs */ for ( k = 0; k < Ny; ++k ) { Nrg[k] = Cy[k][k]; Nrg[k] = Cy_real[k][k]; } /* limit ILDs if DMX energy is lower than sum of channel energies */ Loading @@ -1001,7 +1001,7 @@ static void ivas_param_mc_quantize_ilds( for ( k = 0; k < nchan_transport; k++ ) { dmx_ener += Cx[k][k]; dmx_ener += Cx_real[k][k]; } ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); Loading @@ -1026,7 +1026,7 @@ static void ivas_param_mc_quantize_ilds( for ( k = 0; k < nchan_transport; k++ ) { dmx_ener += Cx[k][k]; dmx_ener += Cx_real[k][k]; } ener_fac = 10.0f * log10f( ( tot_ener + EPSILON ) / ( dmx_ener + EPSILON ) ); Loading Loading @@ -1057,7 +1057,7 @@ static void ivas_param_mc_quantize_ilds( for ( ref_channel_cnt = 0; ref_channel_cnt < h_ild_mapping->num_ref_channels[k]; ref_channel_cnt++ ) { ref_channel_idx = h_ild_mapping->ref_channel_idx[k][ref_channel_cnt]; ref_ener += Cx[ref_channel_idx][ref_channel_idx]; ref_ener += Cx_real[ref_channel_idx][ref_channel_idx]; } ILD[k] = 10.0f * log10f( ( Nrg[h_ild_mapping->ild_index[k]] + EPSILON ) / ( hParamMC->hMetadataPMC.ild_factors[k] * ref_ener + EPSILON ) ); hParamMC->prev_ilds[freq_idx][k] = ILD[k]; Loading Loading @@ -1088,7 +1088,7 @@ static void ivas_param_mc_quantize_ilds( static void ivas_param_mc_quantize_iccs( PARAM_MC_ENC_HANDLE hParamMC, /* i/o: Parametric MC encoder handle */ float Cy[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ float Cy_real[MAX_CICP_CHANNELS][MAX_CICP_CHANNELS], /* i : Covariance matrix of the input */ const int16_t freq_idx, /* i : frequency index being processed */ const int16_t nchan_input, /* i : number of input channels */ int16_t *ICC_idx_out /* o : quantizer indices */ Loading Loading @@ -1129,17 +1129,17 @@ static void ivas_param_mc_quantize_iccs( /* Get ICC matrix from Cy */ for ( k = 0; k < Ny; ++k ) { Nrg[k] = Cy[k][k]; Nrg[k] = Cy_real[k][k]; a = 1.0f / ( sqrtf( Nrg[k] ) + EPSILON ); for ( i = k; i < Ny; ++i ) { Cy[k][i] = Cy[k][i] * a; Cy_real[k][i] = Cy_real[k][i] * a; } for ( i = 0; i <= k; i++ ) { Cy[i][k] = Cy[i][k] * a; Cy_real[i][k] = Cy_real[i][k] * a; } } Loading @@ -1150,12 +1150,12 @@ static void ivas_param_mc_quantize_iccs( { for ( i = k; i < Ny; ++i ) { Cy[k][i] = 1.0f; Cy_real[k][i] = 1.0f; } for ( i = 0; i <= k; ++i ) { Cy[i][k] = 1.0f; Cy_real[i][k] = 1.0f; } } } Loading @@ -1165,7 +1165,7 @@ static void ivas_param_mc_quantize_iccs( { tmp_map[0] = hParamMC->hMetadataPMC.icc_mapping_conf->icc_mapping[k][0]; tmp_map[1] = hParamMC->hMetadataPMC.icc_mapping_conf->icc_mapping[k][1]; ICC_vect[k] = Cy[tmp_map[0]][tmp_map[1]]; ICC_vect[k] = Cy_real[tmp_map[0]][tmp_map[1]]; } /* Quantization */ Loading