Skip to content
......@@ -106,7 +106,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, cons
static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY );
static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands /*, Word16 RealBuffer_fx_e, Word16 ImagBuffer_fx_e, Word16 *common_e*/ );
static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands, const Word16 Cldfb_Real_Imag_exp, Word16 *proto_frame_f_fx_q /* Word16 ImagBuffer_fx_e, Word16 *common_e*/ );
/*-------------------------------------------------------------------------
* ivas_param_mc_dec_open()
......@@ -528,12 +528,15 @@ ivas_error ivas_param_mc_dec_open_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) );
}
set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, cldfb_buf_size );
hParamMC->Cldfb_RealBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases
move16();
IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( cldfb_buf_size * sizeof( Word32 ) ) ) == NULL )
{
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) );
}
set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, cldfb_buf_size );
hParamMC->Cldfb_ImagBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases
move16();
hParamMC->sz = imult1616( imult1616( n_cldfb_slots, nchan_transport ), hParamMC->num_freq_bands );
move16();
......@@ -1983,7 +1986,7 @@ void ivas_param_mc_dec_render_fx(
param_mc_protoSignalComputation_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands],
&hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands],
hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info,
hParamMC->num_freq_bands );
hParamMC->num_freq_bands, hParamMC->Cldfb_RealBuffer_tc_e, &hParamMC->proto_frame_f_fx_q );
/*-----------------------------------------------------------------*
* frequency domain decorrelation
*-----------------------------------------------------------------*/
......@@ -1995,7 +1998,7 @@ void ivas_param_mc_dec_render_fx(
DIRAC_SYNTHESIS_COV_MC_LS,
nchan_transport,
hParamMC->proto_frame_f_fx,
Q5,
hParamMC->proto_frame_f_fx_q,
hParamMC->diff_proto_info->num_protos_diff,
hParamMC->diff_proto_info->proto_index_diff,
hParamMC->proto_frame_dec_f_fx, // output
......@@ -2084,13 +2087,8 @@ void ivas_param_mc_dec_render_fx(
{
IF( hLsSetup.index_lfe[idx_lfe] != ch )
{
#ifdef VEC_ARITH_OPT_v1
v_add_fixed_no_hdrm( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1 );
v_add_fixed_no_hdrm( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1 );
#else /* VEC_ARITH_OPT_v1 */
v_add_fixed( Cldfb_RealBuffer_fx[ch][slot_idx], Cldfb_RealBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_RealBuffer_fx[ch][slot_idx], 1, 0 );
v_add_fixed( Cldfb_ImagBuffer_fx[ch][slot_idx], Cldfb_ImagBuffer_fx[hLsSetup.index_lfe[idx_lfe]][slot_idx], Cldfb_ImagBuffer_fx[ch][slot_idx], 1, 0 );
#endif /* VEC_ARITH_OPT_v1 */
}
}
}
......@@ -2150,6 +2148,7 @@ void ivas_param_mc_dec_render_fx(
}
/* Implement binaural rendering */
/*Binaural output in Q6 format*/
ivas_binRenderer_fx( st_ivas->hBinRenderer,
( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData,
st_ivas->hCombinedOrientationData,
......@@ -2170,19 +2169,7 @@ void ivas_param_mc_dec_render_fx(
}
}
int16_t pos_idx;
FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
{
FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ )
{
FOR( Word16 idx2 = 0; idx2 < hParamMC->subframe_nbslots[subframe_idx]; idx2++ )
{
Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6
Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( Q6, input_q ) ); // Q6
}
}
}
Word16 pos_idx;
IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
......@@ -2232,13 +2219,8 @@ void ivas_param_mc_dec_render_fx(
Word16 len = add( imult1616( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) );
scale_sig32( output_f_fx[ch], len, 5 - 11 );
#ifdef OPT_AVOID_STATE_BUF_RESCALE
cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ),
imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] );
#else /* OPT_AVOID_STATE_BUF_RESCALE */
cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ),
imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, st_ivas->cldfbSynDec[ch] );
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
scale_sig32( output_f_fx[ch], len, 11 - 5 ); // Q11
}
......@@ -2357,8 +2339,9 @@ static void param_mc_protoSignalComputation_fx(
Word32 *ImagBuffer_fx, /* i : CLDFB samples of the transport channels (imaginary part) */
Word32 *proto_frame_f_fx, /* o : interleaved complex prototype CLDFB samples */
const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, /* i : prototype generation information */
const Word16 num_freq_bands /* i : number of frequency bands for the prototypes */
)
const Word16 num_freq_bands, /* i : number of frequency bands for the prototypes */
const Word16 Cldfb_Real_Imag_exp, /*i: Exponent of real and imag buffers */
Word16 *proto_frame_f_fx_q )
{
Word16 band;
Word16 proto_ch_idx, source_ch_cnt;
......@@ -2391,18 +2374,28 @@ static void param_mc_protoSignalComputation_fx(
FOR( band = 0; band < num_freq_bands; band++ )
{
#ifdef FIX_1737_proto_fac_overflow
Word32 tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5
#else
Word32 tmp_x = Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5
#endif
*( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x );
move32();
p_proto_frame_fx++;
#ifdef FIX_1737_proto_fac_overflow
tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5
#else
tmp_x = Mpy_32_32( fac_fx, ( *( p_imag_buffer_fx++ ) ) ); // Q(30 + 6 - 31) :: Q5
#endif
*( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x );
move32();
p_proto_frame_fx++;
}
*proto_frame_f_fx_q = sub( 30, Cldfb_Real_Imag_exp );
move16();
}
}
......@@ -3064,14 +3057,6 @@ static void ivas_param_mc_get_mixing_matrices_fx(
}
/*-------------------------------------------------------------------------
* ivas_param_mc_get_mono_stereo_mixing_matrices()
*
* calculate the direct and residual mixing matrices
* for mono and stereo output
*------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------
* param_mc_update_mixing_matrices()
*
......@@ -3629,7 +3614,11 @@ static ivas_error param_mc_get_diff_proto_info_fx(
{
p_diff_proto_info->source_chan_idx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = cur_transport_ch;
move16();
#ifdef FIX_1737_proto_fac_overflow
p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = *proto_fac_ptr; // (proto_fac_fx)Q26 = Q26
#else
p_diff_proto_info->proto_fac_fx[cur_diff_proto][p_diff_proto_info->num_source_chan_diff[cur_diff_proto]] = L_shl( *proto_fac_ptr, 4 ); // (proto_fac_fx)Q26 + 4 = Q30
#endif
move16();
p_diff_proto_info->num_source_chan_diff[cur_diff_proto] = add( p_diff_proto_info->num_source_chan_diff[cur_diff_proto], 1 );
move16();
......
......@@ -877,6 +877,7 @@ static void ivas_mc_paramupmix_dec_sf(
}
/* Implement binaural rendering */
/*Binaural output in Q6 format*/
ivas_binRenderer_fx( st_ivas->hBinRenderer,
( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData,
st_ivas->hCombinedOrientationData,
......@@ -885,19 +886,7 @@ static void ivas_mc_paramupmix_dec_sf(
Cldfb_RealBuffer_subfr_fx,
Cldfb_ImagBuffer_subfr_fx, &input_q );
int16_t pos_idx;
FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
{
FOR( Word16 idx1 = 0; idx1 < BINAURAL_CHANNELS; idx1++ )
{
FOR( Word16 idx2 = 0; idx2 < MAX_PARAM_SPATIAL_SUBFRAMES; idx2++ )
{
Scale_sig32( Cldfb_RealBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6
Scale_sig32( Cldfb_ImagBuffer_Binaural_fx[pos_idx][idx1][idx2], CLDFB_NO_CHANNELS_MAX, sub( 6, input_q ) ); // Q6
}
}
}
Word16 pos_idx;
IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
{
FOR( pos_idx = 0; pos_idx < st_ivas->hBinRenderer->numPoses; pos_idx++ )
......@@ -913,6 +902,7 @@ static void ivas_mc_paramupmix_dec_sf(
}
}
/* Implement CLDFB synthesis */
FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
{
......@@ -924,28 +914,8 @@ static void ivas_mc_paramupmix_dec_sf(
RealBuffer_fx[slot_idx] = Cldfb_RealBuffer_Binaural_fx[0][ch][slot_idx]; // Q6
ImagBuffer_fx[slot_idx] = Cldfb_ImagBuffer_Binaural_fx[0][ch][slot_idx]; // Q6
}
#ifndef OPT_AVOID_STATE_BUF_RESCALE
scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q5 - Q11 ); // Q11 -> Q5
st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q5;
move16();
cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q5
#else /* OPT_AVOID_STATE_BUF_RESCALE */
cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][0] ), imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6, 0, st_ivas->cldfbSynDec[ch] ); // output_fx returned in Q11
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
#ifndef OPT_AVOID_STATE_BUF_RESCALE
scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, Q11 - Q5 ); // Q5 -> Q11
st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11;
move16();
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
}
#ifndef OPT_AVOID_STATE_BUF_RESCALE
FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ )
{
Scale_sig32( output_fx[ch], imult1616( maxBand, st_ivas->hTcBuffer->subframe_nbslots[subframeIdx] ), 6 ); // Q5 -> Q11
}
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
}
ELSE
{
......@@ -971,13 +941,8 @@ static void ivas_mc_paramupmix_dec_sf(
ptr_re_fx[0] = Cldfb_RealBuffer_fx[ch][slot_idx]; // Q6
ptr_im_fx[0] = Cldfb_ImagBuffer_fx[ch][slot_idx]; // Q6
#ifdef OPT_AVOID_STATE_BUF_RESCALE
cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ),
hMCParamUpmix->num_freq_bands, 0, 0, st_ivas->cldfbSynDec[ch] );
#else /* OPT_AVOID_STATE_BUF_RESCALE */
cldfbSynthesis_ivas_fx( ptr_re_fx, ptr_im_fx, &( pPcm_temp_fx[ch][L_mult0( hMCParamUpmix->num_freq_bands, slot_idx )] ),
hMCParamUpmix->num_freq_bands, 0, st_ivas->cldfbSynDec[ch] );
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
}
scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->cldfb_size, sub( Q11, st_ivas->cldfbSynDec[ch]->Q_cldfb_state ) ); // Q6 -> Q11
st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11;
......
......@@ -198,7 +198,10 @@ void ivas_mct_core_dec(
Word16 tcx_offset;
Word16 tcx_offsetFB;
Word16 left_rect;
Word16 L_spec, scale, tmp1, tmp2;
Word16 L_spec;
#ifndef OPT_SBA_DEC_PATH
Word16 scale, tmp1, tmp2;
#endif /* OPT_SBA_DEC_PATH */
#ifdef DEBUG_MCT
float nrg[MCT_MAX_CHANNELS];
#endif
......@@ -218,11 +221,18 @@ void ivas_mct_core_dec(
move16();
FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
{
#ifndef OPT_SBA_DEC_PATH
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
sts[i] = hCPE[cpe_id]->hCoreCoder[ch];
i = add( i, 1 );
}
#else /* OPT_SBA_DEC_PATH */
FOR( ch = 0; ch < CPE_CHANNELS; ( ch++, i++ ) )
{
sts[i] = hCPE[cpe_id]->hCoreCoder[ch];
}
#endif /* OPT_SBA_DEC_PATH */
}
i = 0;
......@@ -246,7 +256,11 @@ void ivas_mct_core_dec(
move16();
x_fx[ch][0] = signal_out_fx[ch];
x_fx[ch][1] = signal_out_fx[ch] + ( L_FRAME48k / 2 );
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
......@@ -268,7 +282,77 @@ void ivas_mct_core_dec(
{
CONTINUE;
}
#ifdef OPT_SBA_DEC_PATH
IF( EQ_16( st->core, TCX_10_CORE ) )
{
Word16 L_frame_2 = shr( st->L_frame, 1 );
Word16 L_frameTCX_2 = shr( st->hTcxDec->L_frameTCX, 1 );
nSubframes = NB_DIV; // assuming NB_DIV is 2. Below logic needs to be modified if NB_DIV changes.
move16();
FOR( k = 0; k < nSubframes; k++ )
{
L_spec = shr( st->hTcxCfg->tcx_coded_lines, 1 );
move32();
init_tcx_info_fx( st, L_frame_2, L_frameTCX_2, k, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec );
Word16 x_e, x_len;
/* mono or dual mono IGF decoding */
x_e = sub( 31, q_x[ch] );
decoder_tcx_IGF_mono_fx( st, x_fx[ch][k], &x_e, &x_len, L_frame, left_rect, bfi, k );
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
FOR( i = 0; i < x_len; i++ )
{
x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], q_x[ch] );
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
}
ELSE
{
nSubframes = 1;
move16();
{
L_spec = st->hTcxCfg->tcx_coded_lines;
move32();
init_tcx_info_fx( st, st->L_frame, st->hTcxDec->L_frameTCX, 0, bfi, &tcx_offset, &tcx_offsetFB, &L_frame, &L_frameTCX, &left_rect, &L_spec );
Word16 x_e, x_len;
/* mono or dual mono IGF decoding */
x_e = sub( 31, q_x[ch] );
decoder_tcx_IGF_mono_fx( st, x_fx[ch][0], &x_e, &x_len, L_frame, left_rect, bfi, 0 );
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = sub( 31 - 11, x_e ); // Shift to bring x to Q12
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = sub( 31 - 12, x_e ); // Shift to bring x to Q12
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
FOR( i = 0; i < x_len; i++ )
{
x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], q_x[ch] );
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
}
#else /* OPT_SBA_DEC_PATH */
IF( EQ_16( st->core, TCX_10_CORE ) )
{
nSubframes = NB_DIV;
......@@ -298,12 +382,21 @@ void ivas_mct_core_dec(
move16();
FOR( i = 0; i < x_len; i++ )
{
#ifdef OPT_SBA_DEC_V2_NBE
x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q11 ) );
#else /* OPT_SBA_DEC_V2_NBE */
x_fx[ch][k][i] = L_shr( x_fx[ch][k][i], sub( q_x[ch], Q12 ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
#endif /* OPT_SBA_DEC_PATH */
}
}
ELSE
......@@ -318,19 +411,32 @@ void ivas_mct_core_dec(
* MCT processing
*--------------------------------------------------------------------------------*/
#ifdef OPT_SBA_DEC_PATH
apply_MCT_dec_fx( hMCT, sts, x_fx );
#else /* OPT_SBA_DEC_PATH */
apply_MCT_dec_fx( hMCT, sts, x_fx, q_x );
FOR( ch = 0; ch < nChannels; ch++ )
{
FOR( i = 0; i < L_FRAME48k / 2; i++ )
{
#ifdef OPT_SBA_DEC_V2_NBE
x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q11 ) );
x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q11 ) );
#else /* OPT_SBA_DEC_V2_NBE */
x_fx[ch][0][i] = L_shr( x_fx[ch][0][i], sub( q_x[ch], Q12 ) );
x_fx[ch][1][i] = L_shr( x_fx[ch][1][i], sub( q_x[ch], Q12 ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
q_x[ch] = Q11;
#else /* OPT_SBA_DEC_V2_NBE */
q_x[ch] = Q12;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
}
#endif /* OPT_SBA_DEC_PATH */
}
pop_wmops();
......
......@@ -64,7 +64,7 @@ ivas_error ivas_mct_dec_fx(
const Word16 nb_bits_metadata /* i : number of metadata bits */
)
{
Word16 ch, nCPE, cpe_id;
Word16 nCPE, cpe_id;
MCT_DEC_HANDLE hMCT;
CPE_DEC_HANDLE hCPE;
Word16 param[MCT_MAX_BLOCKS][CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV];
......@@ -76,16 +76,19 @@ ivas_error ivas_mct_dec_fx(
Word16 Aq_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; // Q12
Word32 output_lfe_ch_fx[L_FRAME48k];
Word16 q_output = 11;
Word16 n, k, i;
Word16 n, i;
Word32 *x_fx[CPE_CHANNELS][NB_DIV]; //(Q(31 - x_e)
#ifndef OPT_SBA_DEC_V2_NBE
Word16 x_e[MAX_CICP_CHANNELS][NB_DIV];
Word16 ch, k;
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 x_len[CPE_CHANNELS][NB_DIV];
set16_fx( x_len[0], 0, NB_DIV );
set16_fx( x_len[1], 0, NB_DIV );
Decoder_State **sts;
Word32 *p_output_orig_fx[2];
Word32 synth_32_fx[CPE_CHANNELS][L_FRAME_PLUS];
Word32 synth_fx_32[CPE_CHANNELS][L_FRAME_PLUS];
Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; //(Q_synth)
Word32 ivas_total_brate;
ivas_error error;
......@@ -168,7 +171,7 @@ ivas_error ivas_mct_dec_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
p_output_orig_fx[n] = output_fx[n];
output_fx[n] = synth_32_fx[n];
output_fx[n] = synth_fx_32[n];
}
}
......@@ -182,21 +185,31 @@ ivas_error ivas_mct_dec_fx(
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][0] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][1] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
set32_fx( x_fx[n][0], 0, L_FRAME48k / 2 );
set32_fx( x_fx[n][1], 0, L_FRAME48k / 2 );
}
#ifndef OPT_SBA_DEC_V2_NBE
ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id],
fUseTns[cpe_id], tnsData[cpe_id], x_fx, x_e, x_fx, x_e, x_len, Aq_fx[cpe_id], NULL, 1 );
#else /* OPT_SBA_DEC_V2_NBE */
ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id],
fUseTns[cpe_id], tnsData[cpe_id], x_fx, 20, x_fx, 20, x_len, Aq_fx[cpe_id], NULL, 1 );
#endif /* OPT_SBA_DEC_V2_NBE */
#ifndef OPT_SBA_DEC_V2_NBE
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
Word16 subFrames;
......@@ -214,6 +227,7 @@ ivas_error ivas_mct_dec_fx(
Scale_sig32( x_fx[ch][k], shr( L_FRAME48k, sub( subFrames, 1 ) ), sub( x_e[ch][k], 20 ) ); // Scaling back to Q11
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect );
move16();
......@@ -224,18 +238,22 @@ ivas_error ivas_mct_dec_fx(
/* MCT core decoder */
Word16 q_x[MAX_TRANSPORT_CHANNELS];
#ifndef OPT_SBA_DEC_V2_NBE
set16_fx( q_x, Q12, MAX_TRANSPORT_CHANNELS );
// Scaling output buffer to q_x
FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i )
{
Scale_sig32( output_fx[i], L_FRAME48k, sub( q_x[i], Q11 ) ); // Q11 -> Q12
}
#endif /* OPT_SBA_DEC_V2_NBE */
ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output_fx, q_x );
// Scaling output buffer back to Q11
#ifndef OPT_SBA_DEC_V2_NBE
FOR( i = 0; i < hMCT->nchan_out_woLFE; ++i )
{
Scale_sig32( output_fx[i], L_FRAME48k, sub( Q11, q_x[i] ) ); // Q12 -> Q11
}
#endif /* OPT_SBA_DEC_V2_NBE */
/* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/
......@@ -263,16 +281,25 @@ ivas_error ivas_mct_dec_fx(
Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16
x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][0] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
move16();
#ifndef OPT_SBA_DEC_V2_NBE
x_e[n][1] = 20;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
}
#ifndef OPT_SBA_DEC_V2_NBE
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, x_e );
#else /* OPT_SBA_DEC_V2_NBE */
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 );
#endif /* OPT_SBA_DEC_V2_NBE */
#ifndef OPT_SBA_DEC_V2_NBE
FOR( Word16 ind = 0; ind < 2; ind++ )
{
Word16 nSubFrames;
......@@ -291,6 +318,7 @@ ivas_error ivas_mct_dec_fx(
Scale_sig32( x_fx[ind][1], shr( L_FRAME48k, 1 ), sub( x_e[ind][1], 20 ) ); // Q11
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
}
......@@ -347,22 +375,37 @@ ivas_error ivas_mct_dec_fx(
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) );
Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) );
ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig );
#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION
Word16 hdrm;
#else
Word16 hdrm, sh;
#endif
hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
IF( hdrm != 0 )
{
#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION
hdrm = sub( hdrm, 1 );
Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, hdrm );
e_sig[0] = sub( e_sig[0], hdrm );
#else
sh = s_min( sub( e_sig[0], 16 ), hdrm );
Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, sh );
e_sig[0] = sub( e_sig[0], sh );
#endif
move16();
}
hdrm = getScaleFactor16( synth_fx[1], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
IF( hdrm != 0 )
{
#ifdef FIX_ISSUE_1801_NOISE_FLOOR_REDUCTION
hdrm = sub( hdrm, 1 );
Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, hdrm );
e_sig[1] = sub( e_sig[1], hdrm );
#else
sh = s_min( sub( e_sig[1], 16 ), hdrm );
Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, sh );
e_sig[1] = sub( e_sig[1], sh );
#endif
move16();
}
......@@ -390,7 +433,6 @@ ivas_error ivas_mct_dec_fx(
/*----------------------------------------------------------------*
* CoreCoder Post-processing and updates
*----------------------------------------------------------------*/
Word32 synth_fx_32[CPE_CHANNELS][L_FRAME48k];
FOR( n = 0; n < CPE_CHANNELS; n++ )
{
......@@ -1546,11 +1588,7 @@ static ivas_error ivas_mc_dec_reconfig_fx(
}
ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) )
{
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
#else
IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
#endif
{
return error;
}
......
......@@ -165,8 +165,12 @@ void ivas_mct_dec_mct_fx(
static void applyGlobalILD_fx(
Decoder_State **sts,
MCT_DEC_HANDLE hMCT,
Word32 *x[MCT_MAX_CHANNELS][NB_DIV],
Word16 q_x[MCT_MAX_CHANNELS] )
Word32 *x[MCT_MAX_CHANNELS][NB_DIV]
#ifndef OPT_SBA_DEC_PATH
,
Word16 q_x[MCT_MAX_CHANNELS]
#endif /* OPT_SBA_DEC_PATH */
)
{
Word16 ch, k;
Word16 nSubframes, L_subframeTCX;
......@@ -207,9 +211,14 @@ static void applyGlobalILD_fx(
FOR( k = 0; k < nSubframes; k++ )
{
v_multc_fixed( x[ch][k], qratio, x[ch][k], L_subframeTCX ); // Qx - 5 + q_qratio
#ifdef OPT_SBA_DEC_PATH
scale_sig32( x[ch][k], L_subframeTCX, sub( 5, q_qratio ) );
#endif /* OPT_SBA_DEC_PATH */
}
#ifndef OPT_SBA_DEC_PATH
q_x[ch] = add( sub( q_x[ch], 5 ), q_qratio );
move16();
#endif /* OPT_SBA_DEC_PATH */
}
ELSE
{
......@@ -230,8 +239,12 @@ static void applyGlobalILD_fx(
void apply_MCT_dec_fx(
MCT_DEC_HANDLE hMCT, /* i/o: MCT decoder structure */
Decoder_State **sts, /* i/o: decoder state structure */
Word32 *x[MCT_MAX_CHANNELS][NB_DIV], /* i/o: decoded and dequan. spect. input to MCT */
Word16 q_x[MCT_MAX_CHANNELS] )
Word32 *x[MCT_MAX_CHANNELS][NB_DIV] /* i/o: decoded and dequan. spect. input to MCT */
#ifndef OPT_SBA_DEC_PATH
,
Word16 q_x[MCT_MAX_CHANNELS]
#endif /* OPT_SBA_DEC_PATH */
)
{
Word16 pair;
MCT_DEC_BLOCK_DATA_HANDLE hBlock;
......@@ -240,10 +253,18 @@ void apply_MCT_dec_fx(
{
hBlock = hMCT->hBlockData[pair];
#ifndef OPT_SBA_DEC_PATH
stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0, &q_x[hBlock->ch2], &q_x[hBlock->ch1] );
#else /* OPT_SBA_DEC_PATH */
stereo_decoder_tcx_fx( hBlock->hStereoMdct, hBlock->mask, &x[hBlock->ch2][0], &x[hBlock->ch1][0], &x[hBlock->ch2][0], hBlock->hStereoMdct->mdct_stereo_mode, sts[hBlock->ch1]->core, sts[hBlock->ch2]->core, sts[0]->igf, sts[0]->hTcxDec->L_frameTCX, sts[1]->hTcxDec->L_frameTCX, 1, TCX_20_CORE, TCX_20_CORE, 0 );
#endif /* OPT_SBA_DEC_PATH */
}
#ifndef OPT_SBA_DEC_PATH
applyGlobalILD_fx( sts, hMCT, x, q_x );
#else /* OPT_SBA_DEC_PATH */
applyGlobalILD_fx( sts, hMCT, x );
#endif /* OPT_SBA_DEC_PATH */
return;
}
......@@ -302,8 +323,13 @@ void mctStereoIGF_dec_fx(
move16();
// Using input Q-factor as 12
#ifdef OPT_SBA_DEC_V2_NBE
set16_fx( p_x_e[0], 31 - Q11, CPE_CHANNELS ); // Q12
set16_fx( p_x_e[1], 31 - Q11, CPE_CHANNELS ); // Q12
#else /* OPT_SBA_DEC_V2_NBE */
set16_fx( p_x_e[0], 31 - Q12, CPE_CHANNELS ); // Q12
set16_fx( p_x_e[1], 31 - Q12, CPE_CHANNELS ); // Q12
#endif /* OPT_SBA_DEC_V2_NBE */
FOR( k = 0; k < nSubframes; k++ )
{
......@@ -332,13 +358,21 @@ void mctStereoIGF_dec_fx(
decoder_tcx_IGF_stereo_fx( sts, hMCT->hBlockData[b]->hStereoMdct, hMCT->hBlockData[b]->mask, p_x, p_x_e, p_x_len, L_frame[0], left_rect[0], k, bfi, 1 /* MCT_flag */ );
// Shifting output with variable exponent back to Q12
#ifdef OPT_SBA_DEC_V2_NBE
shr_k = sub( 31 - Q11, p_x_e[0][k] );
#else /* OPT_SBA_DEC_V2_NBE */
shr_k = sub( 31 - Q12, p_x_e[0][k] );
#endif /* OPT_SBA_DEC_V2_NBE */
FOR( Word16 i = 0; i < p_x_len[0][k]; i++ )
{
p_x[0][k][i] = L_shr( p_x[0][k][i], shr_k );
move32();
}
#ifdef OPT_SBA_DEC_V2_NBE
shr_k = sub( 31 - Q11, p_x_e[1][k] );
#else /* OPT_SBA_DEC_V2_NBE */
shr_k = sub( 31 - Q12, p_x_e[1][k] );
#endif /* OPT_SBA_DEC_V2_NBE */
FOR( Word16 i = 0; i < p_x_len[1][k]; i++ )
{
p_x[1][k][i] = L_shr( p_x[1][k][i], shr_k );
......@@ -371,7 +405,11 @@ void mctStereoIGF_dec_fx(
/* mono or dual mono IGF decoding */
#ifdef OPT_SBA_DEC_V2_NBE
x_e = 31 - Q11; // input q-factor of x[p_ch[ch]][k] is Q12
#else /* OPT_SBA_DEC_V2_NBE */
x_e = 31 - Q12; // input q-factor of x[p_ch[ch]][k] is Q12
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
decoder_tcx_IGF_mono_fx( st, x[p_ch[ch]][k], &x_e, &x_len, L_frame[ch], left_rect[ch], bfi, k );
......@@ -379,7 +417,11 @@ void mctStereoIGF_dec_fx(
FOR( Word16 i = 0; i < x_len; i++ )
{
// Converting from variable exponent to Fixed q-factor (Q12)
#ifdef OPT_SBA_DEC_V2_NBE
x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q11, x_e ) );
#else /* OPT_SBA_DEC_V2_NBE */
x[p_ch[ch]][k][i] = L_shr( x[p_ch[ch]][k][i], sub( 31 - Q12, x_e ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
}
}
......@@ -431,7 +473,11 @@ void mctStereoIGF_dec_fx(
init_tcx_info_fx( st, L_frame_nSubframe, L_frameTCX_nSubframe, k, bfi, &tcx_offset[0], &tcx_offsetFB[0], &L_frame[0], &L_frameTCX[0], &left_rect[0], &L_spec[0] );
/* mono or dual mono IGF decoding */
#ifdef OPT_SBA_DEC_V2_NBE
x_e = 31 - Q11; // Input Q-factor is Q12.
#else /* OPT_SBA_DEC_V2_NBE */
x_e = 31 - Q12; // Input Q-factor is Q12.
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
decoder_tcx_IGF_mono_fx( st, x[ch][k], &x_e, &x_len, L_frame[0], left_rect[0], bfi, k );
......@@ -439,7 +485,11 @@ void mctStereoIGF_dec_fx(
FOR( Word16 i = 0; i < x_len; i++ )
{
// Converting from variable exponent to Fixed q-factor (Q12)
#ifdef OPT_SBA_DEC_V2_NBE
x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q11, x_e ) );
#else /* OPT_SBA_DEC_V2_NBE */
x[ch][k][i] = L_shr( x[ch][k][i], sub( 31 - Q12, x_e ) );
#endif /* OPT_SBA_DEC_V2_NBE */
move32();
}
}
......
......@@ -630,9 +630,17 @@ void ivas_mdct_core_invQ_fx(
Word16 fUseTns[CPE_CHANNELS][NB_DIV], /* i : flag TNS enabled */
STnsData tnsData[CPE_CHANNELS][NB_DIV], /* i : TNS parameter */
Word32 *x_0[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_0_e,
#else /* OPT_SBA_DEC_V2_NBE */
Word16 x_0_e[CPE_CHANNELS][NB_DIV],
#endif /* OPT_SBA_DEC_V2_NBE */
Word32 *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_e,
#else /* OPT_SBA_DEC_V2_NBE */
Word16 x_e[CPE_CHANNELS][NB_DIV],
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 x_len[CPE_CHANNELS][NB_DIV],
Word16 Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients Q12*/
Word16 ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */
......@@ -737,7 +745,11 @@ void ivas_mdct_core_invQ_fx(
q_r = sub( 30, sts[1]->hTonalMDCTConc->lastBlockData.spectralData_exp );
/* both input in same Q */
#ifndef OPT_SBA_DEC_PATH
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1, &q_r, &q_l );
#else /* OPT_SBA_DEC_PATH */
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0[1], &spectralData_tmp[0], &spectralData_tmp[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 1 );
#endif /* OPT_SBA_DEC_PATH */
Copy_Scale_sig_32_16( spectralData_tmp[0], sts[0]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[0], -15 ); // q_l - 15
Copy_Scale_sig_32_16( spectralData_tmp[1], sts[1]->hTonalMDCTConc->lastBlockData.spectralData, L_frameTCX[1], -15 ); // q_r - 15
......@@ -959,9 +971,11 @@ void ivas_mdct_core_invQ_fx(
IF( EQ_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
{
#ifndef OPT_SBA_DEC_V2_NBE
set32_fx( x[ch][0], 0, st->hTcxCfg->tcx_coded_lines );
x_e[ch][0] = 31;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
/* usually set in decoder_tcx_invQ(), needed for concealment */
st->hTcxDec->damping = 0;
move16();
......@@ -993,6 +1007,10 @@ void ivas_mdct_core_invQ_fx(
FOR( k = 0; k < nSubframes[ch]; k++ )
{
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_e_local = x_e;
Word16 j, diff;
#endif /* OPT_SBA_DEC_V2_NBE */
/* Stability Factor */
IF( !bfi )
{
......@@ -1027,17 +1045,38 @@ void ivas_mdct_core_invQ_fx(
nf_seed = 0;
move16();
decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k );
#ifdef OPT_SBA_DEC_V2_NBE
decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k );
diff = sub( x_e_local, x_0_e );
IF( diff != 0 )
{
FOR( j = 0; j < L_frameTCX[ch]; j++ )
{
x_0[ch][k][j] = L_shl_sat( x[ch][k][j], diff );
move32();
}
}
ELSE
{
Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] );
}
#else /* OPT_SBA_DEC_V2_NBE */
decoder_tcx_invQ_fx( st, prm[ch], Aq[ch], Aind[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, xn_buf, &fUseTns[ch][k], &tnsData[ch][k], &gain_tcx, &gain_tcx_e, &prm_sqQ, &nf_seed, bfi, k );
#endif /* OPT_SBA_DEC_V2_NBE */
shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] );
move16();
Scale_sig32( x[ch][k], L_frameTCX[ch], shift );
#ifdef OPT_SBA_DEC_V2_NBE
x_e_local = sub( x_e_local, shift );
#else /* OPT_SBA_DEC_V2_NBE */
x_e[ch][k] = sub( x_e[ch][k], shift );
move16();
Copy32( x[ch][k], x_0[ch][k], L_frameTCX[ch] );
x_0_e[ch][k] = x_e[ch][k];
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
// PLC to be done
test();
......@@ -1046,15 +1085,29 @@ void ivas_mdct_core_invQ_fx(
TonalMdctConceal_create_concealment_noise_ivas_fx( concealment_noise_fx[ch], &concealment_noise_e[ch], hCPE, L_frameTCX[ch], L_frame[ch], ch, k, st->core, st->hTcxDec->cummulative_damping_tcx, noise_gen_mode_bfi );
}
#ifdef OPT_SBA_DEC_V2_NBE
decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e_local, NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k );
#else /* OPT_SBA_DEC_V2_NBE */
decoder_tcx_noisefilling_fx( st, concealment_noise_fx[ch], concealment_noise_e[ch], Aq[ch], L_frameTCX_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], x[ch][k], &x_e[ch][k], NULL, NULL, &tmp_concealment_method, gain_tcx, gain_tcx_e, prm_sqQ, nf_seed, bfi, MCT_flag, k );
#endif /* OPT_SBA_DEC_V2_NBE */
shift = Find_Max_Norm32( x[ch][k], L_frameTCX[ch] );
move16();
Scale_sig32( x[ch][k], L_frameTCX[ch], shift );
#ifdef OPT_SBA_DEC_V2_NBE
x_e_local = sub( x_e_local, shift );
#else /* OPT_SBA_DEC_V2_NBE */
x_e[ch][k] = sub( x_e[ch][k], shift );
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
#ifdef OPT_SBA_DEC_V2_NBE
decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e_local, &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi );
Scale_sig32( x[ch][k], L_frameTCX[ch], sub( x_e_local, x_e ) );
#else /* OPT_SBA_DEC_V2_NBE */
decoder_tcx_noiseshaping_igf_fx( st, L_spec[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x[ch][k], &x_e[ch][k], &x_len[ch][k], NULL, NULL, &tmp_concealment_method, bfi );
#endif /* OPT_SBA_DEC_V2_NBE */
}
}
}
......@@ -1098,8 +1151,17 @@ void ivas_mdct_core_reconstruct_fx(
Word16 *synthFB_fx;
Word16 q_syn = 0;
move16();
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
Word16 q_win = 0;
Word16 q_winFB = 0;
#else
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT
Word16 q_win = -1;
#else
Word16 q_win = -2;
#endif
move16();
#endif
/* TCX */
Word16 xn_buf_fx[L_MDCT_OVLP_MAX + L_FRAME_PLUS + L_MDCT_OVLP_MAX]; // Q(-2)
Word16 tcx_offset[CPE_CHANNELS];
......@@ -1160,32 +1222,79 @@ void ivas_mdct_core_reconstruct_fx(
st->hTcxDec->q_old_synth = 0;
move16();
}
#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth
Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth
#endif
q_syn = st->hTcxDec->q_old_synth;
move16();
set16_fx( synth_fx, 0, L_FRAME_PLUS + M );
set16_fx( synthFB_fx, 0, L_FRAME_PLUS + M );
IF( st->core != ACELP_CORE )
{
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
Word16 q_win0 = Q15;
move16();
Word16 q_winFB0 = Q15;
move16();
#else
Scale_sig( st->hTcxDec->syn_Overl_TDACFB, L_FRAME_MAX / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDACFB ) ); // st->hTcxDec->Q_syn_Overl_TDACFB -> q_win
st->hTcxDec->Q_syn_Overl_TDACFB = q_win;
move16();
Scale_sig( st->hTcxDec->syn_Overl_TDAC, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_syn_Overl_TDAC ) ); // st->hTcxDec->Q_syn_Overl_TDAC -> q_win
st->hTcxDec->Q_syn_Overl_TDAC = q_win;
move16();
Scale_sig( st->hTcxDec->old_syn_Overl, L_FRAME32k / 2, sub( q_win, st->hTcxDec->Q_old_syn_Overl ) ); // Q(-1 - st->Q_syn) -> q_win
st->hTcxDec->Q_old_syn_Overl = q_win;
move16();
Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win
Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( q_win, st->Q_syn ) ); // Q(st->Q_syn) -> q_win
Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( q_win, st->hHQ_core->Q_old_wtda_LB ) ); // Q(st->hHQ_core->Q_old_wtda_LB) -> q_win
Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( q_win, st->hHQ_core->Q_old_wtda ) ); // Q(st->hHQ_core->Q_old_wtda) -> q_win
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD
st->hHQ_core->Q_old_wtda = q_win;
move16();
st->hHQ_core->Q_old_wtda_LB = q_win;
move16();
#endif
Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win
Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_win, q_syn ) ); // q_syn -> q_win
Scale_sig( st->syn, M + 1, sub( q_win, st->Q_syn ) ); // st->Q_syn -> q_win
#endif
FOR( k = 0; k < nSubframes[ch]; k++ )
{
init_tcx_info_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], k, bfi, &tcx_offset[ch],
&tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] );
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
assert( nSubframes[ch] <= 2 );
q_win0 = q_win;
move16();
q_winFB0 = q_winFB;
move16();
q_win = -2;
move16();
q_winFB = -2;
move16();
#endif
IF( !skip_decoding )
{
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
test();
test();
IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) )
{
decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB,
MDCT_IV, fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 );
}
ELSE
{
decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, &q_win, &q_winFB,
st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 );
}
#else
test();
test();
IF( ( EQ_16( hCPE->nchan_out, 1 ) && EQ_16( st->hTcxDec->kernel_type[k], MDST_IV ) ) || EQ_16( st->hTcxCfg->tcx_last_overlap_mode, TRANSITION_OVERLAP ) )
......@@ -1198,21 +1307,86 @@ void ivas_mdct_core_reconstruct_fx(
decoder_tcx_imdct_fx( st, L_frame_global[ch], L_frame_globalTCX[ch], L_spec[ch], tcx_offset[ch], tcx_offsetFB[ch], L_frame[ch], L_frameTCX[ch], left_rect[ch], x_fx[ch][k], q_x, xn_buf_fx, q_win,
st->hTcxDec->kernel_type[k], fUseTns[ch][k], &synth_fx[k * L_frame[ch]], &synthFB_fx[k * L_frameTCX[ch]], bfi, k, 0 );
}
#endif
}
ELSE
{
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
q_win = Q15;
move16();
q_winFB = Q15;
move16();
#endif
set16_fx( &synth_fx[k * L_frame[ch]], 0, L_frame[ch] );
set16_fx( &synthFB_fx[k * L_frame[ch]], 0, L_frameTCX[ch] );
/* Note: these buffers are not subframe-based, hence no indexing with k */
set16_fx( &st->hHQ_core->old_out_LB_fx[0], 0, L_frame[ch] );
set16_fx( &st->hHQ_core->old_out_fx[0], 0, L_frameTCX[ch] );
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD
st->hHQ_core->Q_old_wtda = Q15;
st->hHQ_core->Q_old_wtda_LB = Q15;
#endif
set16_fx( &st->hTcxDec->syn_Overl[0], 0, shr( L_frame[ch], 1 ) );
set16_fx( &st->hTcxDec->syn_OverlFB[0], 0, shr( L_frameTCX[ch], 1 ) );
set16_fx( &st->hTcxDec->syn_Overl_TDAC[0], 0, shr( L_frame[ch], 1 ) );
set16_fx( &st->hTcxDec->syn_Overl_TDACFB[0], 0, shr( L_frameTCX[ch], 1 ) );
}
}
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
IF( nSubframes[ch] > 1 )
{
Word16 q_winN, q_winFBN;
q_winN = s_min( q_win, q_win0 );
q_winFBN = s_min( q_winFB, q_winFB0 );
// Need to rescale for each subframe, because q_win/q_winFB might had changed for the next subframe. Other OLA buffers are rescaled each time.
Scale_sig( synth_fx, L_frame[ch], sub( q_winN, q_win0 ) ); // q_win -> st->hTcxDec->q_old_synth
Scale_sig( synthFB_fx, L_frameTCX[ch], sub( q_winFBN, q_winFB0 ) ); // q_winFB -> st->hTcxDec->q_old_synth
Scale_sig( synth_fx + L_frame[ch], add( L_frame[ch], M ), sub( q_winN, q_win ) ); // q_win -> st->hTcxDec->q_old_synth
Scale_sig( synthFB_fx + L_frameTCX[ch], add( L_frameTCX[ch], M ), sub( q_winFBN, q_winFB ) ); // q_winFB -> st->hTcxDec->q_old_synth
q_win = q_winN;
move16();
q_winFB = q_winFBN;
move16();
}
Copy_Scale_sig( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len, sub( q_win, st->hTcxDec->q_old_synth ) ); // q_win
Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( q_winFB, st->Q_syn ) ); // q_winFB
test();
IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL )
{
TonalMDCTConceal_SaveTimeSignal_ivas_fx( st->hTonalMDCTConc, synthFB_fx, q_winFB, L_frameTCX[ch] );
}
decoder_tcx_post_ivas_fx( st, synth_fx, synthFB_fx, q_winFB, NULL, bfi, MCT_flag );
// norm(synth_buf) >= q_syn - q_win
// norm(synth_buf) + q_win >= q_syn
sf = s_min( getScaleFactor16( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ) ), getScaleFactor16( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ) ) );
q_syn = add( sub( sf, 1 ), s_min( q_win, q_winFB ) );
st->Q_syn = q_syn;
move16();
// norm(old_out) >= st->Q_syn - q_win
// norm(old_out) + q_win >= st->Q_syn
sf = s_min( getScaleFactor16( st->hHQ_core->old_out_fx, L_FRAME48k ), getScaleFactor16( st->hHQ_core->old_out_LB_fx, L_FRAME32k ) );
st->Q_syn = add( sf, s_min( q_win, q_winFB ) );
Scale_sig( synth_buf_fx, add( add( st->hTcxDec->old_synth_len, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // st->hTcxDec->q_old_synth -> q_syn
Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_winFB ) ); // st->hTcxDec->q_old_synth -> q_syn
// Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) );
Scale_sig( st->syn, M + 1, sub( st->Q_syn, q_win ) );
IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
{
Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, st->prev_Q_syn ) ); // st->Q_syn gets a new value, but st->mem_syn2_fx got its value from E_UTIL_f_preemph3 with st->Q_syn = st->prev_Q_syn
}
ELSE
{
Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, add( q_win, 2 ) ) ); // q_win+2 -> st->Q_syn: in this case, E_UTIL_f_preemph2 shifts st->mem_syn2_fx by 2 bits
}
#else
test();
IF( ( bfi == 0 ) && st->hTonalMDCTConc != NULL )
{
......@@ -1245,16 +1419,33 @@ void ivas_mdct_core_reconstruct_fx(
Scale_sig( synth_bufFB_fx, add( add( st->hTcxDec->old_synth_lenFB, L_FRAME_PLUS ), M ), sub( q_syn, q_win ) ); // q_win -> q_syn
Scale_sig( st->syn, M + 1, add( st->Q_syn, 2 ) );
Scale_sig( st->hTcxDec->syn_OverlFB, L_FRAME_MAX / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn
st->hTcxDec->Q_syn_OverlFB = st->Q_syn;
Scale_sig( st->hTcxDec->syn_Overl, L_FRAME32k / 2, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn
st->hTcxDec->Q_syn_Overl = st->Q_syn;
#ifndef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD
Scale_sig( st->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn
Scale_sig( st->hHQ_core->old_out_fx, L_FRAME48k, sub( st->Q_syn, q_win ) ); // q_win -> st->Q_syn
st->hHQ_core->Q_old_wtda = st->Q_syn;
move16();
st->hHQ_core->Q_old_wtda_LB = st->Q_syn;
move16();
#endif
#endif
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_DYNAMIC_QOLD_NO
Scale_sig( st->mem_syn2_fx, M, sub( st->Q_syn, q_win ) ); // q_win -> Q_syn
#endif
}
ELSE /*ACELP core for ACELP-PLC */
{
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
Copy( st->hTcxDec->old_synth, synth_buf_fx, st->hTcxDec->old_synth_len ); // Q = st->hTcxDec->q_old_synth
Copy_Scale_sig( st->hTcxDec->old_synthFB_fx, synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, sub( st->hTcxDec->q_old_synth, st->Q_syn ) ); // Q = st->hTcxDec->q_old_synth
// Temporary workaround: con_tcx_ivas_fx() should be analyzed for potential issues.
// Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, -2 );
// Scale_sig( synth_bufFB_fx, st->hTcxDec->old_synth_lenFB, +2 );
///////////////////////////////////////////////////////////////////////////////////
#endif
assert( EQ_16( st->bfi, 1 ) );
/* PLC: [TCX: TD PLC] */
IF( MCT_flag != 0 )
......@@ -1283,6 +1474,13 @@ void ivas_mdct_core_reconstruct_fx(
st->Q_syn = q_syn;
move16();
st->hTcxDec->Q_old_syn_Overl = add( st->hTcxDec->Q_old_syn_Overl, q_syn );
move16();
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT_QWIN
st->hTcxDec->Q_syn_OverlFB = add( st->hTcxDec->Q_syn_OverlFB, q_syn );
move16();
// st->hTcxDec->Q_syn_Overl = add( st->hTcxDec->Q_syn_Overl, q_syn ); // It is disabled because it increased the number of regressions.
// move16();
#endif
IF( ( EQ_16( st->nbLostCmpt, 1 ) ) || ( st->hTcxDec->tcxConceal_recalc_exc != 0 ) )
{
......@@ -1454,7 +1652,11 @@ void ivas_mdct_core_tns_ns_fx(
Word32 *x_fx[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS Q(31 - x_e)*/
Word32 Aq_fx[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients Q16*/
const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
#ifdef OPT_SBA_DEC_V2_NBE
Word16 x_e )
#else /* OPT_SBA_DEC_V2_NBE */
Word16 x_e[CPE_CHANNELS][NB_DIV] )
#endif /* OPT_SBA_DEC_V2_NBE */
{
Word16 ch, k, bfi;
Decoder_State **sts, *st;
......@@ -1528,7 +1730,11 @@ void ivas_mdct_core_tns_ns_fx(
&tcx_offsetFB[ch], &L_frame[ch], &L_frameTCX[ch], &left_rect[ch], &L_spec[ch] );
Word16 q_x;
#ifdef OPT_SBA_DEC_V2_NBE
q_x = sub( 31, x_e );
#else /* OPT_SBA_DEC_V2_NBE */
q_x = sub( 31, x_e[ch][k] );
#endif /* OPT_SBA_DEC_V2_NBE */
IF( bfi == 0 )
{
sns_interpolate_scalefactors_fx( sns_int_scf_fx, &Aq_fx[ch][k * M], DEC ); // Q16
......@@ -1547,7 +1753,11 @@ void ivas_mdct_core_tns_ns_fx(
scf_e[ind] = sub( 15, q_shift );
move16();
}
#ifdef OPT_SBA_DEC_V2_NBE
TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e, L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
#else /* OPT_SBA_DEC_V2_NBE */
TonalMDCTConceal_SaveFreqSignal_ivas_fx( st->hTonalMDCTConc, x_fx[ch][k], x_e[ch][k], L_frameTCX[ch], L_frame[ch], &scf_fx[0], scf_e, 0, get_igf_startline( st, L_frame[ch], L_frameTCX[ch] ) );
#endif /* OPT_SBA_DEC_V2_NBE */
}
}
ELSE
......@@ -1609,8 +1819,10 @@ void ivas_mdct_core_tns_ns_fx(
norm_x = getScaleFactor32( &x_fx[ch][k][0], length );
Scale_sig32( &x_fx[ch][k][0], length, norm_x );
q_x = add( q_x, norm_x );
#ifndef OPT_SBA_DEC_V2_NBE
x_e[ch][k] = sub( 31, q_x );
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 q_sns_int_scf;
Word16 q_2;
......@@ -1637,8 +1849,10 @@ void ivas_mdct_core_tns_ns_fx(
Scale_sig32( &x_fx[ch][k][0] + length, sub( length2, length ), sub( add( q_x, 1 ), q_2 ) );
q_x = add( q_x, 1 );
}
#ifndef OPT_SBA_DEC_V2_NBE
x_e[ch][k] = sub( 31, q_x );
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
v_multc_fixed( x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sns_int_scf_fx[FDNS_NPTS - 1], x_fx[ch][k] + st->hTcxCfg->psychParamsCurrent->nBins, sub( L_spec[ch], st->hTcxCfg->psychParamsCurrent->nBins ) );
......@@ -1646,8 +1860,10 @@ void ivas_mdct_core_tns_ns_fx(
Scale_sig32( &x_fx[ch][k][0], st->hTcxCfg->psychParamsCurrent->nBins, sub( q_2, q_x ) );
q_x = q_2;
move16();
#ifndef OPT_SBA_DEC_V2_NBE
x_e[ch][k] = sub( 31, q_x );
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
q_x = sub( q_x, 5 );
length = L_frameTCX[ch];
......@@ -1664,25 +1880,37 @@ void ivas_mdct_core_tns_ns_fx(
}
Scale_sig32( &x_fx[ch][k][0], length, -5 );
decoder_tcx_tns_fx( st, L_frame_global[ch], L_spec[ch], L_frame[ch], L_frameTCX[ch], &x_fx[ch][k][0], fUseTns[ch][k], &tnsData[ch][k], bfi, k, 0, &length );
#ifndef OPT_SBA_DEC_V2_NBE
norm_x = getScaleFactor32( &x_fx[ch][k][0], length );
Scale_sig32( &x_fx[ch][k][0], length, norm_x );
q_x = add( q_x, norm_x );
x_e[ch][k] = sub( 31, q_x );
move16();
#else /* OPT_SBA_DEC_V2_NBE */
Scale_sig32( &x_fx[ch][k][0], length, sub( sub( 31, q_x ), x_e ) );
#endif /* OPT_SBA_DEC_V2_NBE */
}
IF( ( bfi != 0 ) && ( st->tonal_mdct_plc_active != 0 ) )
{
Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16, i;
#ifndef OPT_SBA_DEC_V2_NBE
Word16 tmp_x_fx_exp[L_FRAME48k], temp = -MAX_16;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
Word16 i;
FOR( i = 0; i < FDNS_NPTS; i++ )
{
st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e = s_max( st->hTonalMDCTConc->secondLastBlockData.scaleFactors_max_e, st->hTonalMDCTConc->secondLastBlockData.scaleFactors_exp[i] );
}
#ifndef OPT_SBA_DEC_V2_NBE
set16_fx( tmp_x_fx_exp, x_e[ch][0], L_FRAME48k );
TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], tmp_x_fx_exp, st->hTcxCfg->psychParamsCurrent );
#else /* OPT_SBA_DEC_V2_NBE */
TonalMDCTConceal_Apply_ivas_fx( st->hTonalMDCTConc, x_fx[ch][0], x_e, st->hTcxCfg->psychParamsCurrent );
#endif /* OPT_SBA_DEC_V2_NBE */
#ifndef OPT_SBA_DEC_V2_NBE
FOR( i = 0; i < L_FRAME48k; i++ )
{
temp = s_max( temp, tmp_x_fx_exp[i] );
......@@ -1697,6 +1925,7 @@ void ivas_mdct_core_tns_ns_fx(
move32();
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
}
test();
......
......@@ -318,9 +318,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx(
*------------------------------------------------------------------------*/
void ivas_apply_non_diegetic_panning_fx(
#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING
Word32 *input_f_fx, /* i : non-diegetic object */
#endif
Word32 *output_f_fx[], /* o: core-coder transport mono channel/stereo output */
const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/
const Word16 output_frame /* i : output frame length per channel Q11*/
......@@ -331,13 +329,8 @@ void ivas_apply_non_diegetic_panning_fx(
pan_left_fx = add( mult( non_diegetic_pan_gain_fx, 16384 ), 16384 ); // 0.5.Q15 = 16384
pan_right_fx = sub( 32767, pan_left_fx );
#ifdef FIX_1009_ISM_NONDIEGETIC_PANNING
v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame );
v_multc_fixed( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame );
#else
v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame );
v_multc_fixed( output_f_fx[0], L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame );
#endif
return;
}
......@@ -308,7 +308,7 @@ ivas_error ivas_osba_render_sf_fx(
IF( NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) )
{
ivas_ism_render_sf_fx( st_ivas, p_output_ism, *nSamplesRendered );
ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_ism, *nSamplesRendered );
}
FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
......
......@@ -695,6 +695,11 @@ void ivas_ls_setup_conversion_process_mdct_fx(
Word16 guard_1 = shr( add( find_guarded_bits_fx( tmp_sub ), 1 ), 1 );
Word16 guard_2 = find_guarded_bits_fx( L_mult0( outChannels, inChannels ) );
q_output = sub( q_output, s_max( guard_1, guard_2 ) );
/* Increase the guard bit by 1 to avoid overflow only if q_output is positive */
if ( q_output > 0 )
{
q_output = sub( q_output, 1 );
}
FOR( i = 0; i < inChannels; ++i )
{
......@@ -1028,6 +1033,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
Word16 start, stop, start_tcx5, stop_tcx5;
Word16 mct_chan_mode[MAX_CICP_CHANNELS];
Word16 all_ch_ignored; // Flag for checking if all channels are ignored
/* Declare all handles */
LSSETUP_CONVERSION_HANDLE hLsSetUpConversion;
......@@ -1130,13 +1136,22 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS );
Word16 max_e = 0;
move16();
all_ch_ignored = 1;
move16();
FOR( idx = 0; idx < nchan_transport; idx++ )
{
IF( NE_16( mct_chan_mode[idx], MCT_CHAN_MODE_IGNORE ) )
{
max_e = s_max( max_e, x_e[idx][0] );
all_ch_ignored = 0;
move16();
}
}
if ( all_ch_ignored )
{
max_e = 31;
move16();
}
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
set_zero_fx( real_in_buffer_fx, PARAM_MC_MAX_BANDS_IN_PARAMETER_BAND * PARAM_MC_BAND_TO_MDCT_BAND_RATIO * MAX_TRANSPORT_CHANNELS );
......@@ -1164,6 +1179,10 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
}
}
}
input_exp = max_e;
move16();
IF( all_ch_ignored == 0 )
{
Word16 shift = 1;
move16();
FOR( i = 0; i < num_bands * nchan_transport; ++i )
......@@ -1173,13 +1192,19 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
imag_in_buffer_fx[i] = L_shr( imag_in_buffer_fx[i], shift );
move32();
}
input_exp = max_e;
move16();
input_exp = add( input_exp, shift );
}
cmplx_matrix_square_fx( real_in_buffer_fx, imag_in_buffer_fx, num_bands, nchan_transport, real_buffer_fx, imag_buffer_fx, input_exp, &output_exp );
v_add_32( cx_fx[bandIdx], real_buffer_fx, cx_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/
v_add_32( cx_imag_fx[bandIdx], imag_buffer_fx, cx_imag_fx[bandIdx], i_mult( nchan_transport, nchan_transport ) ); /*Q=Q_real_buffer=Q_imag_buffer=output_exp*/
}
if ( all_ch_ignored )
{
output_exp = 29;
move16();
}
Word16 exp_in = 10, exp_out = 0;
move16();
move16();
......@@ -1190,7 +1215,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
set_zero_fx( cy_fx, MAX_CICP_CHANNELS * MAX_CICP_CHANNELS );
set_zero_fx( Nrqq_fx, MAX_OUTPUT_CHANNELS );
set_zero_fx( target_ch_ener_fx, MAX_OUTPUT_CHANNELS );
/* Step 1.2, get target channel energies for the transported format as in ivas_param_mc_get_mono_stereo_mixing_matrices(), Nrqq calculation */
/* Step 1.2, get target channel energies for the transported format, Nrqq calculation */
ild_q_fx = hParamMC->icld_q_fx + imult1616( bandIdx, hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe );
move16();
FOR( chInIdx = 0; chInIdx < nchan_transport_format; chInIdx++ )
......@@ -1212,7 +1237,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
move32();
}
/* 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) */
/* Step 1.3 get target Cy () (with dmx matrix from CICPX to MONO/STEREO saved in hParamMC) */
FOR( chOutIdx = 0; chOutIdx < nchan_out; chOutIdx++ )
{
FOR( i = 0; i < nchan_transport_format; i++ )
......
......@@ -112,6 +112,9 @@ void ivas_post_proc_fx(
{
Word16 numZeros = (Word16) ( NS2SA_FX2( output_Fs, N_ZERO_MDCT_NS ) ); /*Q0*/
move16();
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT
assert( sts[n]->hHQ_core->Q_old_out_fx32 == Q11 );
#endif
Copy32( sts[n]->hHQ_core->old_out_fx32 + numZeros, sts[n]->hTcxDec->FBTCXdelayBuf_32, delay_comp ); /*Q11*/
}
......@@ -588,7 +591,11 @@ void stereo_dft_dec_core_switching_fx(
Word32 tmp_fade_fx[max( STEREO_DFT_ALLPASS_FADELEN_12k8, STEREO_DFT_ALLPASS_FADELEN_16k )];
Copy32( st->hHQ_core->old_out_LB_fx32 + numZeros, hCPE->hStereoDft->ap_fade_mem_fx, ap_fade_len ); /*st->hHQ_core->q_old_outLB_fx*/
#ifdef FIX_1348_BIT_PRECISION_IMPROVEMENT
hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->Q_old_out_fx32;
#else
hCPE->hStereoDft->q_ap_fade_mem_fx = st->hHQ_core->q_old_outLB_fx;
#endif
move16();
test();
......
......@@ -77,7 +77,7 @@ void ivas_sba2mc_cldfb_fixed(
FOR( m = 0; m < nb_channels_in; m++ )
{
g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29
g_fx = L_shl_sat( hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )], Q2 );
p_realOut_fx = realOut_fx[n];
p_imagOut_fx = imagOut_fx[n];
......@@ -87,9 +87,9 @@ void ivas_sba2mc_cldfb_fixed(
p_imag_fx = ImagBuffer[m][iBlock]; /*Q_imag*/
FOR( iBand = 0; iBand < nb_bands; iBand++ )
{
*p_realOut_fx = L_add( *p_realOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ) ); // Q_real
*p_realOut_fx = Madd_32_32( *p_realOut_fx, g_fx, *( p_real_fx++ ) ); // Q_real
move32();
*p_imagOut_fx = L_add( *p_imagOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_imag_fx++ ) ) ); // Q_imag
*p_imagOut_fx = Madd_32_32( *p_imagOut_fx, g_fx, *( p_imag_fx++ ) ); // Q_imag
move32();
p_realOut_fx++;
p_imagOut_fx++;
......@@ -167,7 +167,7 @@ void ivas_mc2sba_fx(
/* Add LFE to omni W with gain*/
FOR( k = 0; k < output_frame; k++ )
{
buffer_tmp_fx[0][k] = L_add( buffer_tmp_fx[0][k], L_shl( Mult_32_16( in_buffer_td_fx[i][k], gain_lfe_fx ), 1 ) ); /*Q+14-15+1==Q*/
buffer_tmp_fx[0][k] = Madd_32_16( buffer_tmp_fx[0][k], L_shl( in_buffer_td_fx[i][k], 1 ), gain_lfe_fx ); /*Q+14-15+1==Q*/
move32();
}
}
......@@ -196,7 +196,7 @@ void ivas_mc2sba_fx(
{
FOR( k = 0; k < output_frame; k++ )
{
buffer_tmp_fx[j][k] = L_add( buffer_tmp_fx[j][k], L_shl( Mult_32_32( in_buffer_td_fx[i][k], gains_fx[j] ), 2 ) ); /*Q+29-31+2==Q*/
buffer_tmp_fx[j][k] = Madd_32_32( buffer_tmp_fx[j][k], L_shl_sat( in_buffer_td_fx[i][k], 2 ), gains_fx[j] ); /*Q+29-31+2==Q*/
move32();
}
}
......@@ -505,7 +505,7 @@ void ivas_sba_mix_matrix_determiner_fx(
temp_fx = MAX16B; /*Q0*/
move32();
}
ELSE IF( LT_32( temp_fx, L_negate( PCM16_TO_FLT_FAC_FX ) ) )
ELSE IF( LT_32( temp_fx, -( PCM16_TO_FLT_FAC_FX ) ) )
{
temp_fx = -( PCM16_TO_FLT_FAC_FX ); /*Q0*/
move32();
......
......@@ -787,11 +787,7 @@ void ivas_spar_get_cldfb_gains_fx(
cldfbAnalysis_ts_fx_fixed_q( ts_inout_fx, ts_re_fx, ts_im_fx, num_cldfb_bands, cldfbAnaDec0, &q_cldfb );
cldfb_reset_memory_fx( cldfbSynDec0 );
#ifdef OPT_AVOID_STATE_BUF_RESCALE
cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, 0, cldfbSynDec0 );
#else /* OPT_AVOID_STATE_BUF_RESCALE */
cldfbSynthesis_ivas_fx( pp_ts_re_fx, pp_ts_im_fx, ts_inout_fx, num_cldfb_bands, 0, cldfbSynDec0 );
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
FOR( sample = 0; sample < stride; sample++ )
{
T_fx[( ( slot * stride ) + sample )][slot] = ts_inout_fx[sample]; /*Q21*/
......@@ -1163,6 +1159,69 @@ void ivas_spar_get_parameters_fx(
move16();
Word16 add_weight_fx = sub( MAX_WORD16, weight_fx );
Word16 add_weight_20ms_fx = sub( MAX_WORD16, weight_20ms_fx );
#ifdef OPT_SBA_DEC_V2_BE
Word16 out_flag[IVAS_MAX_FB_MIXER_OUT_CH];
Word32 band_bool = LT_16( split_band, IVAS_MAX_NUM_BANDS );
FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
{
/* 20ms cross-fade for Transport channels in all frequency bands */
/* sub-frame processing for missing channels in all frequency bands*/
out_flag[out_ch] = band_bool && ( 0 == ivas_is_res_channel( out_ch, hSpar->hMdDec->spar_md_cfg.nchan_transport ) );
move16();
}
Word32 frame_bool = GT_16( hSpar->i_subframe, 3 );
FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
{
IF( out_flag[out_ch] )
{
IF( frame_bool )
{
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
{
par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[ts1][out_ch][in_ch][spar_band], weight_fx ),
hSpar->hMdDec->mixer_mat_prev_fx[ts0][out_ch][in_ch][spar_band], add_weight_fx );
move32();
}
}
}
ELSE
{
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
{
{
par_mat_fx[out_ch][in_ch][spar_band] = hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band]; /*hSpar->hMdDec->Q_mixer_mat*/
move32();
}
}
}
}
}
ELSE
{
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
{
/* 20ms Transport channel reconstruction with matching encoder/decoder processing */
Word16 prev_idx = SPAR_DIRAC_SPLIT_START_BAND < IVAS_MAX_NUM_BANDS ? 1 : 0; /* if SPAR_DIRAC_SPLIT_START_BAND == IVAS_MAX_NUM_BANDS, then the sub-frame mixer_mat delay line is not active */
move16();
par_mat_fx[out_ch][in_ch][spar_band] = Madd_32_16( Mpy_32_16_1( hSpar->hMdDec->mixer_mat_prev_fx[prev_idx][out_ch][in_ch][spar_band], add_weight_20ms_fx ),
hSpar->hMdDec->mixer_mat_fx[out_ch][in_ch][spar_band], weight_20ms_fx ); /*hSpar->hMdDec->Q_mixer_mat*/
move32();
}
}
}
}
#else /* OPT_SBA_DEC_V2_BE */
FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
{
FOR( out_ch = 0; out_ch < num_ch_out; out_ch++ )
......@@ -1202,7 +1261,7 @@ void ivas_spar_get_parameters_fx(
}
}
}
#endif /* OPT_SBA_DEC_V2_BE */
return;
}
......@@ -2041,11 +2100,7 @@ void ivas_spar_dec_upmixer_sf_fx(
{
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
#ifdef OPT_AVOID_STATE_BUF_RESCALE
cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[idx_in] );
#else /* OPT_AVOID_STATE_BUF_RESCALE */
cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[idx_in][ts], &cldfb_in_ts_im_fx[idx_in][ts], &output_fx[ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[idx_in] );
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
}
}
......@@ -2060,11 +2115,7 @@ void ivas_spar_dec_upmixer_sf_fx(
{
FOR( ts = 0; ts < hSpar->subframe_nbslots[hSpar->subframes_rendered]; ts++ )
{
#ifdef OPT_AVOID_STATE_BUF_RESCALE
cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, 0, st_ivas->cldfbSynDec[out_ch] );
#else /* OPT_AVOID_STATE_BUF_RESCALE */
cldfbSynthesis_ivas_fx( &cldfb_in_ts_re_fx[out_ch][ts], &cldfb_in_ts_im_fx[out_ch][ts], &output_fx[out_ch][i_mult( ts, num_cldfb_bands )], num_cldfb_bands, 6, st_ivas->cldfbSynDec[out_ch] );
#endif /* OPT_AVOID_STATE_BUF_RESCALE */
}
}
}
......
......@@ -44,6 +44,9 @@
/*------------------------------------------------------------------------------------------*
* Local constants
*------------------------------------------------------------------------------------------*/
#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC
#define DEG180_BY_PI_Q24 ( (Word32) 0x394BB835 ) /* 180.0/PI in Q24) */
#endif
#define IVAS_DEFAULT_DTX_CNG_RAMP ( 8 )
......@@ -1318,6 +1321,14 @@ static void ivas_get_spar_matrices_fx(
tmp_C2_re_fx[0][j] = Mpy_32_32( active_w_dm_fac_fx, L_negate( hMdDec->spar_md.band_coeffs[( b + ( i_ts * IVAS_MAX_NUM_BANDS ) )].pred_re_fx[j - 1] ) ); // Q31 *Q22=Q22
move32();
}
#ifdef OPT_SBA_DEC_V2_BE
re_fx1 = Madd_32_32( ONE_IN_Q13, tmp_C2_re_fx[0][1], tmp_C1_re_fx[1][0] ); // Q13+Q13
re_fx1 = Madd_32_32( re_fx1, tmp_C2_re_fx[0][2], tmp_C1_re_fx[2][0] ); // Q13+Q13
tmp_dm_re_fx[0][0] = L_shl( Madd_32_32( re_fx1, tmp_C2_re_fx[0][3], tmp_C1_re_fx[3][0] ), Q9 ); // (Q13+Q13) << Q9 = Q22;
//
#else /* OPT_SBA_DEC_V2_BE */
re_fx = Mpy_32_32( tmp_C2_re_fx[0][1], tmp_C1_re_fx[1][0] ); // Q22 *Q22 =Q13
re_fx1 = L_add( ONE_IN_Q13, re_fx ); // Q13+Q13
......@@ -1326,6 +1337,7 @@ static void ivas_get_spar_matrices_fx(
re_fx = Mpy_32_32( tmp_C2_re_fx[0][3], tmp_C1_re_fx[3][0] ); // Q22 *Q22 =Q13
tmp_dm_re_fx[0][0] = L_shl( L_add( re_fx1, re_fx ), Q9 ); // (Q13+Q13) << Q9 = Q22;
#endif /* OPT_SBA_DEC_V2_BE */
move32();
IF( EQ_16( dyn_active_w_flag, 1 ) )
......@@ -1401,7 +1413,11 @@ static void ivas_get_spar_matrices_fx(
{
FOR( k = dmx_ch; k < numch_out; k++ )
{
#ifndef OPT_SBA_DEC_V2_BE
IF( EQ_16( sub( j, dmx_ch ), sub( k, dmx_ch ) ) )
#else /* OPT_SBA_DEC_V2_BE */
IF( EQ_16( j, k ) )
#endif /* OPT_SBA_DEC_V2_BE */
{
tmpP_re_fx[j][k] = hMdDec->spar_md.band_coeffs[add( b, i_mult( i_ts, IVAS_MAX_NUM_BANDS ) )].P_re_fx[sub( k, dmx_ch )]; // Q22
move32();
......@@ -1702,7 +1718,7 @@ static void ivas_spar_dec_parse_md_bs_fx(
{
*nB = SPAR_DTX_BANDS;
move16();
*bands_bw = idiv1616( num_bands, *nB ); /*Q0*/
*bands_bw = shr( num_bands, SPAR_DTX_BANDS_LOG2 ); /*Q0*/
move16();
FOR( i = 0; i < *nB; i++ )
......@@ -2946,8 +2962,13 @@ void ivas_spar_to_dirac_fx(
radius_fx = Sqrt32( temp, &q_temp );
Word16 check_azi_fx = BASOP_util_atan2( dvy_fx[band], dvx_fx[band], 0 ); /*Q13*/
Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/
#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC
Word32 azi_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_azi_fx );
#else
Word16 check_azi_fx_res;
Word32 check_azi_fx_32 = L_shl( check_azi_fx, 16 ); /*Q29*/
IF( check_azi_fx_32 < 0 )
{
check_azi_fx_res = negate( divide3232( L_negate( check_azi_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/
......@@ -2957,6 +2978,8 @@ void ivas_spar_to_dirac_fx(
check_azi_fx_res = divide3232( check_azi_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/
}
Word32 azi_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_azi_fx_res ); /*Q22*/
#endif
azi_intermediate = L_add( azi_intermediate, ONE_IN_Q21 ); /*Q22*/
Word16 azi_res;
......@@ -2970,9 +2993,14 @@ void ivas_spar_to_dirac_fx(
}
Word16 check_ele_fx = BASOP_util_atan2( dvz_fx[band], radius_fx, sub( add( 9, q_dvnorm ), q_temp ) ); /*Q13*/
Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/
#ifdef FIX_ISSUE_1744_IVAS_SPAR_TO_DIRAC
Word32 ele_intermediate = Mpy_32_16_1( DEG180_BY_PI_Q24, check_ele_fx );
#else
Word16 check_ele_fx_res;
IF( check_azi_fx_32 < 0 )
Word32 check_ele_fx_32 = L_shl( check_ele_fx, 16 ); /*Q29*/
IF( check_ele_fx_32 < 0 )
{
check_ele_fx_res = negate( divide3232( L_negate( check_ele_fx_32 ), 1686629760 /*3.145f in Q29*/ ) ); /*Q15*/
}
......@@ -2981,6 +3009,7 @@ void ivas_spar_to_dirac_fx(
check_ele_fx_res = divide3232( check_ele_fx_32, 1686629760 /*3.145f in Q29*/ ); /*Q15*/
}
Word32 ele_intermediate = Mpy_32_16_1( DEGREE_180_Q_22, check_ele_fx_res ); /*Q22*/
#endif
ele_intermediate = L_add( ele_intermediate, ONE_IN_Q21 ); /*Q22*/
Word16 ele_res;
......
......@@ -574,7 +574,7 @@ typedef struct ivas_param_mc_dec_data_structure
Word32 *proto_matrix_int_fx;
Word16 proto_matrix_int_len;
Word16 proto_matrix_int_e;
Word16 proto_frame_f_fx_q;
/*sub-modules*/
HANDLE_DIRAC_DECORR_PARAMS h_freq_domain_decorr_ap_params;
HANDLE_DIRAC_DECORR_STATE h_freq_domain_decorr_ap_state;
......@@ -1121,9 +1121,7 @@ typedef struct Decoder_Struct
HRTFS_CREND_HANDLE hSetOfHRTF; /* Set of HRTFs handle (CRend) */
HRTFS_FASTCONV_HANDLE hHrtfFastConv; /* FASTCONV HRTF tables for binaural rendering */
HRTFS_PARAMBIN_HANDLE hHrtfParambin; /* HRTF tables for parametric binauralizer */
#ifdef NONBE_FIX_922_PRECOMPUTED_HRTF_PROPERTIES
HRTFS_STATISTICS_HANDLE hHrtfStatistics; /* HRTF statistics handle */
#endif
LSSETUP_CUSTOM_HANDLE hLsSetupCustom; /* Custom LS configuration handle */
Word32 *hoa_dec_mtx; /* Pointer to decoder matrix for SBA */
HEAD_TRACK_DATA_HANDLE hHeadTrackData; /* Head tracking data structure */
......
......@@ -1446,11 +1446,7 @@ void stereo_cna_update_params_fx(
{
IF( EQ_16( hCPE->nchan_out, 1 ) )
{
#ifdef OPT_STEREO_32KBPS_V1
c_LR_fx = MAX_32;
#else /* OPT_STEREO_32KBPS_V1 */
c_LR_fx = MAX_WORD16;
#endif /* OPT_STEREO_32KBPS_V1 */
move32();
c_ILD_fx = 0;
move32();
......@@ -1513,11 +1509,7 @@ void stereo_cna_update_params_fx(
dotLR_fx_q = add( dotLR_fx_q, sub( sub( 31, temp_res_q ), 31 ) );
dotLR_fx = W_deposit32_l( L_shl_sat( W_extract_l( dotLR_fx ), sub( 31, dotLR_fx_q ) ) ); /* Q31 */
/* estimate L/R correlation factor and ILD in time domain */
#ifdef OPT_STEREO_32KBPS_V1
c_LR_fx = W_extract_l( dotLR_fx ); /* Q31 */
#else /* OPT_STEREO_32KBPS_V1 */
c_LR_fx = extract_h( W_extract_l( dotLR_fx ) ); /* Q15 */
#endif /* OPT_STEREO_32KBPS_V1 */
temp_res_q = 0;
move16();
......@@ -1556,24 +1548,15 @@ void stereo_cna_update_params_fx(
/* update of long-term ILD and LR correlation factors for stereo CNA */
IF( !hFdCngDec->first_cna_noise_updated )
{
#ifdef OPT_STEREO_32KBPS_V1
hFdCngDec->cna_LR_LT_fx = extract_h( c_LR_fx );
#else /* OPT_STEREO_32KBPS_V1 */
hFdCngDec->cna_LR_LT_fx = extract_l( c_LR_fx );
#endif /* OPT_STEREO_32KBPS_V1 */
move16();
hFdCngDec->cna_ILD_LT_fx = extract_l( c_ILD_fx );
move16();
}
ELSE
{
#ifdef OPT_STEREO_32KBPS_V1
hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ),
Mpy_32_32( ONE_IN_Q31 - STEREO_CNA_LR_CORR_LT_FILT_FX, c_LR_fx ) ) ); /* Q31 */
#else /* OPT_STEREO_32KBPS_V1 */
hFdCngDec->cna_LR_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_LR_CORR_LT_FILT_FX, hFdCngDec->cna_LR_LT_fx ),
Mpy_32_16_1( L_sub( ONE_IN_Q31, STEREO_CNA_LR_CORR_LT_FILT_FX ), extract_l( c_LR_fx ) ) ) ); /* Q31 */
#endif /* OPT_STEREO_32KBPS_V1 */
move16();
hFdCngDec->cna_ILD_LT_fx = extract_h( L_add_sat( Mpy_32_16_1( STEREO_CNA_ILD_LT_FILT_FX, hFdCngDec->cna_ILD_LT_fx ),
......
......@@ -378,15 +378,8 @@ void stereo_dft_unify_dmx_fx(
Word16 idx_k0, idx_k1;
Word16 q_shift0;
Word16 q_shift1;
#ifdef NONBE_FIX_1006_PAST_DMX_NRG_ERROR
idx_k0 = add( hStereoDft->past_DMX_pos, STEREO_DFT_PAST_MAX - 1 ) & ( STEREO_DFT_PAST_MAX - 1 ); /* Q0 */
idx_k1 = add( idx_k0, 1 ) & ( STEREO_DFT_PAST_MAX - 1 );
#else
idx_k0 = ( add( hStereoDft->past_DMX_pos, 1 ) ) % STEREO_DFT_PAST_MAX;
move16();
idx_k1 = ( add( idx_k0, 1 ) ) % STEREO_DFT_PAST_MAX;
move16();
#endif
q_shift0 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k0] );
q_shift1 = sub( hStereoDft->q_dft, hStereoDft->q_DFT_past_DMX_fx[idx_k1] );
......
......@@ -1881,10 +1881,6 @@ void stereo_dft_dec_fx(
HANDLE_FD_CNG_COM hFdCngCom = hFdCngDec->hFdCngCom;
Word16 *cna_seed = &( hFdCngCom->seed );
Word32 DFT_W, DFT_Y;
#ifndef OPT_STEREO_32KBPS_V1
Word16 q_samp_ratio = Q15;
move16();
#endif /* OPT_STEREO_32KBPS_V1 */
Word16 len;
output_frame = (Word16) Mpy_32_32( L_add( st0->output_Fs, FRAMES_PER_SEC_BY_2 ), ONE_BY_FRAMES_PER_SEC_Q31 ); /* Q0 */
......@@ -1893,12 +1889,7 @@ void stereo_dft_dec_fx(
* Initialization
*-----------------------------------------------------------------*/
#ifdef OPT_STEREO_32KBPS_V1
samp_ratio = divide3232( st0->sr_core, st0->output_Fs ); // Q15
#else /* OPT_STEREO_32KBPS_V1 */
samp_ratio = (Word16) BASOP_Util_Divide3232_Scale( st0->sr_core, st0->output_Fs, &q_samp_ratio );
samp_ratio = shr( samp_ratio, sub( Q15 - Q12, q_samp_ratio ) );
#endif /* OPT_STEREO_32KBPS_V1 */
stop = shr( STEREO_DFT32MS_N_32k, 1 );
......@@ -2473,17 +2464,10 @@ void stereo_dft_dec_fx(
/*Nyquist Freq.*/
IF( EQ_16( hStereoDft->band_limits[b], shr( hStereoDft->NFFT, 1 ) ) )
{
#ifdef OPT_STEREO_32KBPS_V1
DFT_L[1] = Madd_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */
move32();
DFT_R[1] = Msub_32_16( pDFT_DMX[1], pDFT_DMX[1], g ); /* qDFT */
move32();
#else /* OPT_STEREO_32KBPS_V1 */
DFT_L[1] = L_add( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */
move32();
DFT_R[1] = L_sub( pDFT_DMX[1], Mpy_32_16_1( pDFT_DMX[1], g ) ); /* qDFT */
move32();
#endif /* OPT_STEREO_32KBPS_V1 */
DFT_L[1] = Mpy_32_16_1( DFT_L[1], INV_SQRT2_FX_Q15 ); /* qDFT */
move32();
DFT_R[1] = Mpy_32_16_1( DFT_R[1], INV_SQRT2_FX_Q15 ); /* qDFT */
......@@ -2608,7 +2592,7 @@ void stereo_dft_dec_fx(
q_cna_level = hFdCngDec->smoothed_psd_exp;
move16();
l_tmp = Sqrt32( cna_level, &q_cna_level );
scale_fact = Mpy_32_32( l_tmp, scale_fact0 ); /* q_cna_level */
scale_fact = Mpy_32_32( l_tmp, scale_fact0 ); /* Q = (31-q_cna_level) + Q15 - 31 */
/*
scale_fact0 will be in Q15 by the time the above operation is performed
so the q of scale_fact represented now by q_cna_level has to be updated
......@@ -2616,52 +2600,28 @@ void stereo_dft_dec_fx(
q_cna_level = sub( Q31, add( q_cna_level, Q16 ) );
/* generate comfort noise from gaussian noise and add to the decoded DFT spectrum */
#ifdef OPT_STEREO_32KBPS_V1
Word16 shift = sub( q_cna_level, hStereoDft->q_dft );
#endif /* OPT_STEREO_32KBPS_V1 */
N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */
N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */
#ifdef OPT_STEREO_32KBPS_V1
l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */
l_tmp = L_shr( l_tmp, shift ); /* q_dft */
#else /* OPT_STEREO_32KBPS_V1 */
l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */
l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */
#endif /* OPT_STEREO_32KBPS_V1 */
DFT_L[2 * i] = L_add( DFT_L[2 * i], l_tmp ); /* q_dft */
DFT_L[2 * i] = L_add_sat( DFT_L[2 * i], l_tmp ); /* q_dft */
move32();
#ifdef OPT_STEREO_32KBPS_V1
l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */
l_tmp = L_shr( l_tmp, shift ); /* q_dft */
DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */
#else /* OPT_STEREO_32KBPS_V1 */
l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */
l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */
DFT_R[2 * i] = L_add( DFT_R[2 * i], l_tmp ); /* q_dft */
#endif /* OPT_STEREO_32KBPS_V1 */
DFT_R[2 * i] = L_add_sat( DFT_R[2 * i], l_tmp ); /* q_dft */
move32();
N1 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */
N2 = L_shl( Mpy_32_16_1( scale_fact, rand_gauss_fix( &ftmp, cna_seed ) ), Q2 ); /* q_cna_level */
#ifdef OPT_STEREO_32KBPS_V1
l_tmp = Madd_32_16( Madd_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */
l_tmp = L_shr( l_tmp, shift ); /* q_dft */
DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */
DFT_L[2 * i + 1] = L_add_sat( DFT_L[2 * i + 1], l_tmp ); /* q_dft */
move32();
l_tmp = Msub_32_16( Msub_32_16( N1, N1, g ), N2, gamma ); /* q_cna_level */
l_tmp = L_shr( l_tmp, shift ); /* q_dft */
DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */
move32();
#else /* OPT_STEREO_32KBPS_V1 */
l_tmp = L_add( Madd_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */
l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */
DFT_L[2 * i + 1] = L_add( DFT_L[2 * i + 1], l_tmp ); /* q_dft */
DFT_R[2 * i + 1] = L_add_sat( DFT_R[2 * i + 1], l_tmp ); /* q_dft */
move32();
l_tmp = L_sub( Msub_32_16( N1, N1, g ), Mpy_32_16_1( N2, gamma ) ); /* q_cna_level */
l_tmp = L_shr( l_tmp, sub( q_cna_level, hStereoDft->q_dft ) ); /* q_dft */
DFT_R[2 * i + 1] = L_add( DFT_R[2 * i + 1], l_tmp ); /* q_dft */
move32();
#endif /* OPT_STEREO_32KBPS_V1 */
}
}
......@@ -2749,12 +2709,7 @@ static void stereo_dft_compute_td_stefi_params_fx(
return;
}
#ifdef OPT_STEREO_32KBPS_V1
bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) );
#else /* OPT_STEREO_32KBPS_V1 */
bin0 = extract_l( L_shr_r( Mpy_32_16_1( (Word32) hStereoDft->NFFT, samp_ratio ), 1 ) ); /* Q0 */
bin0 = shl( bin0, Q3 );
#endif /* OPT_STEREO_32KBPS_V1 */
bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */
b = hStereoDft->nbands; /* Q0 */
move16();
......@@ -2919,11 +2874,7 @@ static void stereo_dft_dequantize_ipd_fx(
*-------------------------------------------------------------------------*/
void stereo_dft_generate_res_pred_fx(
STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */
#ifdef OPT_STEREO_32KBPS_V1
const Word16 samp_ratio, /* i : sampling ratio Q15*/
#else /* OPT_STEREO_32KBPS_V1 */
const Word16 samp_ratio, /* i : sampling ratio Q13*/
#endif /* OPT_STEREO_32KBPS_V1 */
Word32 *pDFT_DMX, /* i : downmix signal qDFT*/
Word32 *DFT_PRED_RES, /* o : residual prediction signal qDFT*/
Word32 *pPredGain, /* i : residual prediction gains Q31*/
......@@ -2941,9 +2892,6 @@ void stereo_dft_generate_res_pred_fx(
/* variables for enhanced stereo filling */
Word16 norm_fac, q_norm_fac;
#ifndef OPT_STEREO_32KBPS_V1
Word16 lim_norm_fac;
#endif /* OPT_STEREO_32KBPS_V1 */
Word16 q_sqrt;
Word16 alpha; // gain_limit;
......@@ -2957,12 +2905,7 @@ void stereo_dft_generate_res_pred_fx(
Word32 pred_gain_avg;
Word32 g2;
Word16 nbands_respred;
#ifdef OPT_STEREO_32KBPS_V1
Word16 q_new, diff;
#else /* OPT_STEREO_32KBPS_V1 */
q_norm_fac = 0;
move16();
#endif /* OPT_STEREO_32KBPS_V1 */
Word16 len;
push_wmops( "gen_respred" );
......@@ -2985,12 +2928,7 @@ void stereo_dft_generate_res_pred_fx(
/* In ACELP mode the downmix signal is not available in bandwidth extension area. *
* Therefore, the downmix energy in the corresponding subbands is estimated. */
#ifdef OPT_STEREO_32KBPS_V1
bin0 = round_fx( L_mult0( hStereoDft->NFFT, samp_ratio ) );
#else /* OPT_STEREO_32KBPS_V1 */
bin0 = (Word16) ( L_shr( L_add( L_mult0( hStereoDft->NFFT, samp_ratio ), ONE_IN_Q12 ), Q12 + 1 ) ); /* Q0 */
move16();
#endif /* OPT_STEREO_32KBPS_V1 */
bin0 = s_min( bin0, hStereoDft->band_limits[hStereoDft->nbands] ); /* Q0 */
b = hStereoDft->nbands;
move16();
......@@ -3035,22 +2973,12 @@ void stereo_dft_generate_res_pred_fx(
len = s_min( hStereoDft->band_limits[b + 1], bin0 );
FOR( i = hStereoDft->band_limits[b]; i < len; i++ )
{
#ifdef OPT_STEREO_32KBPS_V1
dmx_nrg_64bit = W_mac_32_32( W_mac_32_32( dmx_nrg_64bit, pDFT_DMX[2 * i], pDFT_DMX[2 * i] ),
pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */
rev_nrg_64bit = W_mac_32_32( W_mac_32_32( rev_nrg_64bit, ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ),
ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ); /* 2 * q_dft + 1 */
#else /* OPT_STEREO_32KBPS_V1 */
dmx_nrg_64bit = W_add( dmx_nrg_64bit,
W_add( W_mult0_32_32( pDFT_DMX[2 * i], pDFT_DMX[2 * i] ),
W_mult0_32_32( pDFT_DMX[2 * i + 1], pDFT_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */
rev_nrg_64bit = W_add( rev_nrg_64bit,
W_add( W_mult0_32_32( ap_filt_DMX[2 * i], ap_filt_DMX[2 * i] ),
W_mult0_32_32( ap_filt_DMX[2 * i + 1], ap_filt_DMX[2 * i + 1] ) ) ); /* 2 * q_dft */
#endif /* OPT_STEREO_32KBPS_V1 */
}
#ifdef OPT_STEREO_32KBPS_V1
q_new = add( shl( hStereoDft->q_dft, 1 ), 1 );
q_shift = W_norm( dmx_nrg_64bit );
dmx_nrg = W_shl_sat_l( dmx_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32)
......@@ -3059,54 +2987,26 @@ void stereo_dft_generate_res_pred_fx(
rev_nrg = W_shl_sat_l( rev_nrg_64bit, sub( q_shift, 32 ) ); // 2 * hStereoDft->q_dft + 1 - (q_shift - 32)
rev_nrg_q = add( q_new, sub( q_shift, 32 ) );
move16();
#else /* OPT_STEREO_32KBPS_V1 */
q_shift = W_norm( dmx_nrg_64bit );
dmx_nrg = W_extract_l( W_shl( dmx_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32)
dmx_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) );
q_shift = W_norm( rev_nrg_64bit );
rev_nrg = W_extract_l( W_shl( rev_nrg_64bit, sub( q_shift, 32 ) ) ); // 2 * hStereoDft->q_dft + (q_shift - 32)
rev_nrg_q = add( imult1616( 2, hStereoDft->q_dft ), sub( q_shift, 32 ) );
#endif /* OPT_STEREO_32KBPS_V1 */
/* Reach a common Q for dmx_nrg and rev_nrg */
q_com = s_min( dmx_nrg_q, rev_nrg_q );
dmx_nrg = L_shl( dmx_nrg, sub( q_com, dmx_nrg_q ) ); /* q_com */
rev_nrg = L_shl( rev_nrg, sub( q_com, rev_nrg_q ) ); /* q_com */
#ifdef OPT_STEREO_32KBPS_V1
diff = sub( hStereoDft->q_smoothed_nrg, q_com );
IF( diff < 0 )
#else /* OPT_STEREO_32KBPS_V1 */
IF( LT_16( hStereoDft->q_smoothed_nrg, q_com ) )
#endif /* OPT_STEREO_32KBPS_V1 */
{
#ifdef OPT_STEREO_32KBPS_V1
rev_nrg = L_shl( rev_nrg, shl( diff, 1 ) );
dmx_nrg = L_shl( dmx_nrg, shl( diff, 1 ) );
#else /* OPT_STEREO_32KBPS_V1 */
rev_nrg = L_shr( rev_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) );
dmx_nrg = L_shr( dmx_nrg, shl( sub( q_com, hStereoDft->q_smoothed_nrg ), 1 ) );
#endif /* OPT_STEREO_32KBPS_V1 */
q_com = hStereoDft->q_smoothed_nrg;
move16();
}
#ifdef OPT_STEREO_32KBPS_V1
ELSE
#else /* OPT_STEREO_32KBPS_V1 */
ELSE IF( GT_16( hStereoDft->q_smoothed_nrg, q_com ) )
#endif /* OPT_STEREO_32KBPS_V1 */
{
#ifdef OPT_STEREO_32KBPS_V1
hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */
move32();
hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( diff, 1 ) ); /* hStereoDft->q_smoothed_nrg */
move32();
#else /* OPT_STEREO_32KBPS_V1 */
hStereoDft->smooth_res_nrg_fx[b] = L_shr( hStereoDft->smooth_res_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */
move32();
hStereoDft->smooth_dmx_nrg_fx[b] = L_shr( hStereoDft->smooth_dmx_nrg_fx[b], shl( sub( hStereoDft->q_smoothed_nrg, q_com ), 1 ) ); /* hStereoDft->q_smoothed_nrg */
move32();
#endif /* OPT_STEREO_32KBPS_V1 */
q_smoothed_nrg_local[b] = q_com;
move16();
}
......@@ -3116,15 +3016,12 @@ void stereo_dft_generate_res_pred_fx(
hStereoDft->smooth_dmx_nrg_fx[b] = Madd_32_16( Mpy_32_16_1( hStereoDft->smooth_dmx_nrg_fx[b], alpha ), dmx_nrg, sub( (Word16) ( 0x7FFF ), alpha ) ); /* hStereoDft->q_smoothed_nrg */
move32();
#ifdef OPT_STEREO_32KBPS_V1
// Compute norm_fac in Q14
norm_fac = MAX_16;
move16();
#endif /* OPT_STEREO_32KBPS_V1 */
/* normalization factor */
IF( hStereoDft->smooth_res_nrg_fx[b] != 0 )
{
#ifdef OPT_STEREO_32KBPS_V1
norm_fac = 0;
move16();
IF( hStereoDft->smooth_dmx_nrg_fx[b] != 0 )
......@@ -3147,88 +3044,15 @@ void stereo_dft_generate_res_pred_fx(
norm_fac = extract_h( prod );
}
#else /* OPT_STEREO_32KBPS_V1 */
norm_fac = BASOP_Util_Divide3232_Scale( hStereoDft->smooth_dmx_nrg_fx[b], hStereoDft->smooth_res_nrg_fx[b], &q_norm_fac ); /* q_norm_fac */
norm_fac = Sqrt16( norm_fac, &q_norm_fac );
IF( norm_fac != 0 )
{
/* gain compressor */
test();
test();
test();
test();
test();
test();
test();
test();
IF( LE_16( q_norm_fac, -Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && GT_16( (Word16) 0x3333, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) )
{
lim_norm_fac = (Word16) 0x5000;
move16();
}
ELSE IF( GT_16( q_norm_fac, Q1 ) || ( EQ_16( q_norm_fac, Q1 ) && LT_16( (Word16) 0x5000, norm_fac ) ) || ( ( q_norm_fac == 0 ) && GT_16( (Word16) 0x6666, norm_fac ) ) )
{
lim_norm_fac = (Word16) 0x3333;
move16();
}
ELSE
{
lim_norm_fac = norm_fac;
move16();
}
IF( EQ_16( lim_norm_fac, norm_fac ) )
{
norm_fac = ONE_IN_Q14;
move16();
q_norm_fac = Q1;
move16();
}
ELSE
{
norm_fac = extract_l( L_shr( L_mult0( norm_fac, lim_norm_fac ), Q15 ) ); /* q_norm_fac */
q_norm_fac = add( q_norm_fac, 1 );
test();
IF( q_norm_fac < 0 )
{
norm_fac = shl( norm_fac, q_norm_fac );
q_norm_fac = 0;
move16();
}
ELSE IF( GT_16( q_norm_fac, 2 ) && LT_16( norm_s( norm_fac ), sub( q_norm_fac, Q1 ) ) )
{
norm_fac = MAX_16;
move16();
q_norm_fac = Q1;
move16();
}
}
}
#endif /* OPT_STEREO_32KBPS_V1 */
}
#ifndef OPT_STEREO_32KBPS_V1
ELSE
{
norm_fac = MAX_16;
move16();
q_norm_fac = Q1;
move16();
}
#endif /* OPT_STEREO_32KBPS_V1 */
len = s_min( hStereoDft->band_limits[b + 1], bin0 );
FOR( i = hStereoDft->band_limits[b]; i < len; i++ )
{
#ifdef OPT_STEREO_32KBPS_V1
DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), 1 ); /* q_dft */
move32();
DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), 1 ); /* q_dft */
move32();
#else /* OPT_STEREO_32KBPS_V1 */
DFT_PRED_RES[2 * i] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i] ), q_norm_fac ); /* q_dft */
move32();
DFT_PRED_RES[2 * i + 1] = L_shl( Mpy_32_32( Mpy_32_16_1( pPredGain[b], norm_fac ), ap_filt_DMX[2 * i + 1] ), q_norm_fac ); /* q_dft */
move32();
#endif /* OPT_STEREO_32KBPS_V1 */
}
}
......
......@@ -904,9 +904,7 @@ void stereo_icBWE_dec_fx(
winSlope_fx = div_s( 1, winLen_fx ); /* Q15 */
alpha_fx = winSlope_fx; /* Q15 */
move16();
#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx
Word16 winSlope_fx_ = sub( 32767 /* 1.0 in Q15*/, winSlope_fx );
#endif
FOR( i = 0; i < winLen_fx; i++ )
{
L_tmp = L_mult0( alpha_fx, icbweM2Ref_fx ); /* Q29 */
......@@ -914,17 +912,10 @@ void stereo_icBWE_dec_fx(
tmp = shl( round_fx( L_tmp ), 1 ); /* Q14 */
synthRef_fx[i] = Mpy_32_16_1( synthRef_fx[i], tmp ); /* Qsyn - 1 */
move32();
#ifdef FIX_1439_SPEEDUP_stereo_icBWE_dec_fx
if ( LE_16( alpha_fx, winSlope_fx_ ) )
{
alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */
}
#else
IF( LE_16( alpha_fx, sub( 32767 /* 1.0 in Q15*/, winSlope_fx ) ) )
{
alpha_fx = add( alpha_fx, winSlope_fx ); /* Q15 */
}
#endif
}
FOR( ; i < NS2SA_FX2( st->output_Fs, FRAME_SIZE_NS ); i++ )
......
......@@ -178,7 +178,9 @@ void stereo_mdct_core_dec_fx(
/*needed to allocate N_MAX to prevent stereo switching crash */
Word32 x_0_buf_fx[CPE_CHANNELS][N_MAX];
Word32 *x_0_fx[CPE_CHANNELS][NB_DIV];
#ifndef OPT_SBA_DEC_V2_NBE
Word16 x_0_e[CPE_CHANNELS][NB_DIV];
#endif /* OPT_SBA_DEC_V2_NBE */
/* Concealment */
Word16 bfi;
......@@ -289,15 +291,24 @@ void stereo_mdct_core_dec_fx(
{
FOR( j = 0; j < NB_DIV; ++j )
{
#ifndef OPT_SBA_DEC_V2_NBE
x_e[i][j] = 31;
#else /* OPT_SBA_DEC_V2_NBE */
x_e[i][j] = 20;
#endif /* OPT_SBA_DEC_V2_NBE */
move16();
x_len[i][j] = 0;
move16();
#ifndef OPT_SBA_DEC_V2_NBE
x_0_e[i][j] = 31;
move16();
#endif /* OPT_SBA_DEC_V2_NBE */
}
}
#ifdef OPT_SBA_DEC_V2_NBE
ivas_mdct_core_invQ_fx( hCPE, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0_fx, 20, x_fx, 20, x_len, Aq_fx, ms_mask, 0 );
#else /* OPT_SBA_DEC_V2_NBE */
ivas_mdct_core_invQ_fx( hCPE, nTnsBitsTCX10, p_param, param_lpc, param, fUseTns, tnsData, x_0_fx, x_0_e, x_fx, x_e, x_len, Aq_fx, ms_mask, 0 );
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
......@@ -323,6 +334,7 @@ void stereo_mdct_core_dec_fx(
move16();
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
FOR( ch = 0; ch < nChannels; ch++ )
{
......@@ -465,9 +477,13 @@ void stereo_mdct_core_dec_fx(
test();
IF( ( !bfi || ( sts[0]->core != ACELP_CORE || sts[1]->core != ACELP_CORE ) ) && !hCPE->hStereoMdct->isSBAStereoMode )
{
#ifndef OPT_SBA_DEC_PATH
Word16 q_x_1 = 11, q_x_0 = 11;
move16();
move16();
#endif /* OPT_SBA_DEC_PATH */
#ifndef OPT_SBA_DEC_V2_NBE
FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
{
......@@ -477,9 +493,18 @@ void stereo_mdct_core_dec_fx(
move16();
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
#ifdef OPT_SBA_DEC_PATH
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0 );
#else /* OPT_SBA_DEC_PATH */
stereo_decoder_tcx_fx( hCPE->hStereoMdct, ms_mask, x_0_fx[1], x_fx[0], x_fx[1], &hCPE->hStereoMdct->mdct_stereo_mode[0], sts[0]->core, sts[1]->core, sts[0]->igf, L_frameTCX[0], L_frameTCX[1], 0, sts[0]->last_core, sts[1]->last_core, 0, &q_x_1, &q_x_0 );
#endif /* OPT_SBA_DEC_PATH */
}
#ifdef OPT_SBA_DEC_V2_NBE
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, 20 );
#else /* OPT_SBA_DEC_V2_NBE */
ivas_mdct_core_tns_ns_fx( hCPE, fUseTns, tnsData, x_fx, Aq_fx_32, 0, x_e );
FOR( Word16 ind = 0; ind < 2; ind++ )
......@@ -505,7 +530,7 @@ void stereo_mdct_core_dec_fx(
move16();
}
}
#endif /* OPT_SBA_DEC_V2_NBE */
test();
test();
IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
......
......@@ -313,9 +313,13 @@ void stereo_decoder_tcx_fx(
const Word16 mct_on, /* i : flag mct block (1) or stereo (0) Q0*/
const Word16 last_core_l, /* i : last core for left channel Q0*/
const Word16 last_core_r, /* i : last core for right channel Q0*/
const Word16 tmp_plc_upmix, /* i : indicates temp upmix for PLC decision Q0*/
const Word16 tmp_plc_upmix /* i : indicates temp upmix for PLC decision Q0*/
#ifndef OPT_SBA_DEC_PATH
,
Word16 *q_x_ch2,
Word16 *q_x_ch1 )
Word16 *q_x_ch1
#endif /* OPT_SBA_DEC_PATH */
)
{
Word16 i, k, sfb, nSubframes;
STEREO_MDCT_BAND_PARAMETERS *sfbConf = NULL;
......@@ -361,10 +365,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseMS_fx( sfbConf->sfbOffset[sfbConf->nBandsStereoCore], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED );
#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
#endif /* OPT_SBA_DEC_PATH */
}
ELSE IF( EQ_16( mdct_stereo_mode[k], SMDCT_BW_MS ) )
{
......@@ -381,10 +387,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED );
#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
#endif /* OPT_SBA_DEC_PATH */
}
}
}
......@@ -402,10 +410,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseMS_fx( sub( sfbConf->sfbOffset[sfbConf->sfbCnt], sfbConf->sfbOffset[sfbConf->nBandsStereoCore] ), &spec_l[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], &spec_r[k][sfbConf->sfbOffset[sfbConf->nBandsStereoCore]], SQRT2_OVER_2_FIXED );
#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
#endif /* OPT_SBA_DEC_PATH */
}
ELSE IF( EQ_16( hStereoMdct->IGFStereoMode[k], SMDCT_BW_MS ) )
{
......@@ -422,10 +432,12 @@ void stereo_decoder_tcx_fx(
}
}
inverseBwMS_fx( sfbConf->sfbOffset[sfb], sfbConf->sfbOffset[sfb + 1], spec_l[k], spec_r[k], SQRT2_OVER_2_FIXED );
#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
*q_x_ch1 = *q_x_ch1;
move16();
#endif /* OPT_SBA_DEC_PATH */
}
}
}
......@@ -483,8 +495,10 @@ void stereo_decoder_tcx_fx(
nrgRatio = L_shl( nrgRatio, shift ); /* Q26 + shift */
v_multc_fixed( spec_r[k], nrgRatio, spec_r[k], L_frameTCX_r ); /* spec_r will be in Qx + shift - Q5 */
Scale_sig32( spec_r[k], L_frameTCX_r, sub( 5, shift ) ); /* Qx */
#ifndef OPT_SBA_DEC_PATH
*q_x_ch2 = *q_x_ch2;
move16();
#endif /* OPT_SBA_DEC_PATH */
}
ELSE IF( ( LT_32( nrgRatio, ONE_IN_Q26 ) ) && ( LT_16( k, tmp2 ) ) )
{
......@@ -492,8 +506,10 @@ void stereo_decoder_tcx_fx(
shift = sub( 5, tmp_e );
v_multc_fixed( spec_l[k], inv_nrgRatio, spec_l[k], L_frameTCX_l ); /* spec_r will be in Qx - tmp_e */
Scale_sig32( spec_l[k], L_frameTCX_l, sub( 5, shift ) ); /* Qx */
#ifndef OPT_SBA_DEC_PATH
*q_x_ch1 = *q_x_ch1;
move16();
#endif /* OPT_SBA_DEC_PATH */
}
}
} /* for k */
......