Skip to content
......@@ -1968,10 +1968,13 @@ void ivas_param_mc_dec_render_fx(
slot_idx_start_cldfb_synth = 0;
move16();
#ifndef FIX_1009_OPT_PARAMMC_RENDER
Flag is_zero = 1;
move32();
#endif
FOR( j = 0; j < st_ivas->hParamMC->hMetadataPMC->nbands_coded; j++ )
{
#ifndef FIX_1009_OPT_PARAMMC_RENDER
is_zero = 1;
move16();
FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_len; i++ )
......@@ -1989,8 +1992,19 @@ void ivas_param_mc_dec_render_fx(
}
is_zero = 1;
move16();
#else
Flag is_zero = is_zero_arr( hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx[j], hParamMC->h_output_synthesis_cov_state.mixing_matrix_len );
{
if ( is_zero != 0 )
{
hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp[j] = 0;
move16();
}
}
#endif
IF( LT_16( st_ivas->hParamMC->band_grouping[j], st_ivas->hParamMC->h_output_synthesis_params.max_band_decorr ) )
{
#ifndef FIX_1009_OPT_PARAMMC_RENDER
FOR( i = 0; i < hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len; i++ )
{
IF( NE_32( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[j][i], 0 ) )
......@@ -2000,6 +2014,10 @@ void ivas_param_mc_dec_render_fx(
}
}
IF( is_zero )
#else
is_zero = is_zero_arr( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx[j], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_len );
if ( is_zero != 0 )
#endif
{
hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp[j] = 0;
move16();
......
......@@ -31,8 +31,8 @@
*******************************************************************************************************/
#include <assert.h>
#include "options.h"
#include <stdint.h>
#include "options.h"
#include "cnst.h"
#include "prot.h"
#include "prot_fx.h"
......@@ -40,6 +40,7 @@
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "ivas_cnst.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#include "math.h"
......
......@@ -315,6 +315,7 @@ void mctStereoIGF_dec_fx(
test();
IF( NE_16( hMCT->hBlockData[b]->hStereoMdct->IGFStereoMode[k], SMDCT_DUAL_MONO ) || NE_16( hMCT->hBlockData[b]->hStereoMdct->mdct_stereo_mode[k], SMDCT_DUAL_MONO ) )
{
#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
tmp = BASOP_Util_Divide1616_Scale( sts[0]->hTcxCfg->tcx_coded_lines, nSubframes, &tmp_e );
L_spec[0] = shr( tmp, add( 15, negate( tmp_e ) ) );
move16();
......@@ -324,6 +325,18 @@ void mctStereoIGF_dec_fx(
tmp = BASOP_Util_Divide1616_Scale( sts[0]->hTcxDec->L_frameTCX, nSubframes, &tmp_e );
L_frameTCX_nSubframe = shr( tmp, add( 15, negate( tmp_e ) ) );
#else
Word16 shr_div, shr_k;
assert( nSubframes == 1 || nSubframes == 2 );
/* Note: nSubframes is in limited range [1, 2] for this function */
shr_div = sub( nSubframes, 1 ); /* 2 -> 1, 1 -> 0 */
L_spec[0] = shr( sts[0]->hTcxCfg->tcx_coded_lines, shr_div );
move16();
L_frame_nSubframe = shr( sts[0]->L_frame, shr_div );
L_frameTCX_nSubframe = shr( sts[0]->hTcxDec->L_frameTCX, shr_div );
#endif
init_tcx_info_fx( sts[0], 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] );
......@@ -333,14 +346,28 @@ 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 FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
shr_k = sub( 31 - Q12, p_x_e[0][k] );
#endif
FOR( Word16 i = 0; i < p_x_len[0][k]; i++ )
{
#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
p_x[0][k][i] = L_shr( p_x[0][k][i], sub( 31 - Q12, p_x_e[0][k] ) );
#else
p_x[0][k][i] = L_shr( p_x[0][k][i], shr_k );
#endif
move32();
}
#ifdef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
shr_k = sub( 31 - Q12, p_x_e[1][k] );
#endif
FOR( Word16 i = 0; i < p_x_len[1][k]; i++ )
{
#ifndef FIX_1109_OPTIM_MCT_STEREO_IGF_DEC
p_x[1][k][i] = L_shr( p_x[1][k][i], sub( 31 - Q12, p_x_e[1][k] ) );
#else
p_x[1][k][i] = L_shr( p_x[1][k][i], shr_k );
#endif
move32();
}
}
......
......@@ -1168,7 +1168,12 @@ void ivas_mdct_core_reconstruct_fx(
}
synth_fx = synth_buf_fx + st->hTcxDec->old_synth_len;
synthFB_fx = synth_bufFB_fx + st->hTcxDec->old_synth_lenFB;
test();
if ( is_zero_arr16( st->hTcxDec->old_synth, st->hTcxDec->old_synth_len ) && is_zero_arr16( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synth_lenFB ) )
{
st->hTcxDec->q_old_synth = 0;
move16();
}
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
q_syn = st->hTcxDec->q_old_synth;
......
......@@ -51,10 +51,8 @@
#define LS_OUT_CONV_SMOOTHING_FACTOR_Q31 93415539
#define LS_OUT_CONV_CLIP_FACTOR_MAX_Q29 1073741824
#define LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28 1073741824
#define LS_OUT_CONV_CLIP_FACTOR_MIN_Q29 161061274
#define LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28 24159191
#define LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 2147483647
#define LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 322122547
/*----------------------------------------------------------------------------------*
......@@ -62,24 +60,12 @@
*----------------------------------------------------------------------------------*/
static void ivas_lssetupconversion_computeEQFactor_fx(
Word32 *outputEnergy, // Q0
Word32 *inputEnergy, // Q0
Word32 *outputEnergy,
Word16 output_exp,
Word32 *inputEnergy,
Word16 input_exp,
Word32 *EQ )
{
IF( GE_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MAX_SQ_Q28, *inputEnergy ) ) )
{
*EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MAX_Q29, 1 ); // Q30
move32();
return;
}
IF( LE_32( L_shr( *outputEnergy, 3 ), Mpy_32_32( LS_OUT_CONV_CLIP_FACTOR_MIN_SQ_Q28, *inputEnergy ) ) )
{
*EQ = L_shl_sat( LS_OUT_CONV_CLIP_FACTOR_MIN_Q29, 1 ); // Q30
move32();
return;
}
test();
IF( ( *outputEnergy == 0 ) && ( *inputEnergy == 0 ) )
{
......@@ -90,9 +76,16 @@ static void ivas_lssetupconversion_computeEQFactor_fx(
/* Compute the Equalization Gain */
Word16 tmp_e;
Word16 tmp = BASOP_Util_Divide3232_Scale( *outputEnergy, L_add( EPSILON_FX, *inputEnergy ), &tmp_e );
Word32 tmp_32 = L_shl( (Word32) tmp, 16 );
tmp_e = add( tmp_e, sub( output_exp, input_exp ) );
Word32 tmp_32 = L_deposit_h( tmp );
tmp_32 = Sqrt32( tmp_32, &tmp_e );
*EQ = L_shr( tmp_32, 1 - tmp_e );
*EQ = L_shr_sat( tmp_32, sub( 1, tmp_e ) ); // range of EQ in float 0.3 - 2.0
move32();
*EQ = L_min( *EQ, LS_OUT_CONV_CLIP_FACTOR_MAX_Q30 );
*EQ = L_max( *EQ, LS_OUT_CONV_CLIP_FACTOR_MIN_Q30 );
move32();
move32();
return;
}
......@@ -437,10 +430,10 @@ ivas_error ivas_ls_setup_conversion_open_fx(
return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) );
}
set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt );
hLsSetUpConversion->te_prev_exp = 0;
hLsSetUpConversion->te_prev_exp[chIdx] = 0;
move16();
set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt );
hLsSetUpConversion->dmx_prev_exp = 0;
hLsSetUpConversion->dmx_prev_exp[chIdx] = 0;
move16();
}
FOR( ; chIdx < MAX_CICP_CHANNELS; chIdx++ )
......@@ -857,21 +850,31 @@ void ivas_ls_setup_conversion_process_mdct_fx(
} /* end of out channel loop */
/* Step 3: Peform energy smoothing */
Word16 te_scale = getScaleFactor32( hLsSetUpConversion->targetEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt );
scale_sig32( hLsSetUpConversion->targetEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt, te_scale );
Word16 dmx_sacle = getScaleFactor32( hLsSetUpConversion->dmxEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt );
scale_sig32( hLsSetUpConversion->dmxEnergyPrev_fx[0], hLsSetUpConversion->sfbCnt, dmx_sacle );
Word16 te_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) );
Word16 dmx_max_e = s_max( sub( 40, shl( q_output, 1 ) ), sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) );
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] ) );
targetEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( targetEnergy[bandIdx], sub( te_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], sub( te_max_e, sub( hLsSetUpConversion->te_prev_exp[0], te_scale ) ) ) ) );
move32();
dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[bandIdx] ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] ) );
dmxEnergy[bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[bandIdx], sub( dmx_max_e, sub( 40, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( ( ONE_IN_Q31 - LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[0], dmx_sacle ) ) ) ) );
move32();
hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; // exp( hLsSetUpConversion->te_prev_exp) (Q0 here)
hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy[bandIdx]; /* te_prev_exp = 40 - 2*q_output */
move32();
hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; // exp( hLsSetUpConversion->dmx_prev_exp) (Q0)
hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; /* dmx_prev_exp = 40 - 2*q_output */
move32();
hLsSetUpConversion->te_prev_exp = 31;
}
hLsSetUpConversion->te_prev_exp[0] = te_max_e; /* te_prev_exp = 40 - 2*q_output */
move16();
hLsSetUpConversion->dmx_prev_exp = 31;
hLsSetUpConversion->dmx_prev_exp[0] = dmx_max_e; /* dmx_prev_exp = 40 - 2*q_output */
move16();
}
FOR( i = 0; i < inChannels; ++i )
{
......@@ -901,7 +904,7 @@ void ivas_ls_setup_conversion_process_mdct_fx(
move16();
/* Compute Eq gains */
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain ); // Q(eqGain) = 30
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain ); // Q(eqGain) = 30
FOR( binIdx = start; binIdx < stop; binIdx++ )
{
x[chInIdx][0][binIdx] = Mpy_32_32( L_shl( x[chInIdx][0][binIdx], 1 ), eqGain ); // Q - 1
......@@ -921,7 +924,7 @@ void ivas_ls_setup_conversion_process_mdct_fx(
move16();
/* Compute Eq gains */
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], &dmxEnergy[bandIdx], &eqGain );
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain );
FOR( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
{
......@@ -1261,18 +1264,18 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
/* Step 3: Peform energy smoothing */
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], add( output_exp, sub( 2, hLsSetUpConversion->te_prev_exp ) ) ) ) ); /*output_exp + 2*/
targetEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx], add( output_exp, sub( 2, hLsSetUpConversion->te_prev_exp[0] ) ) ) ) ); /*output_exp + 2*/
move32();
dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( shl( add( max_e, 2 ), 1 ), hLsSetUpConversion->dmx_prev_exp ) ) ) ); /*2 * (max_e + 2)*/
dmxEnergy_fx[bandIdx] = L_add( Mult_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy_fx[bandIdx] ), Mult_32_32( L_sub( MAX_32, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx], sub( shl( add( max_e, 2 ), 1 ), hLsSetUpConversion->dmx_prev_exp[0] ) ) ) ); /*2 * (max_e + 2)*/
move32();
hLsSetUpConversion->targetEnergyPrev_fx[0][bandIdx] = targetEnergy_fx[bandIdx];
move32();
hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy_fx[bandIdx];
move32();
}
hLsSetUpConversion->te_prev_exp = add( output_exp, 2 );
hLsSetUpConversion->te_prev_exp[0] = add( output_exp, 2 );
move16();
hLsSetUpConversion->dmx_prev_exp = shl( add( max_e, 2 ), 1 );
hLsSetUpConversion->dmx_prev_exp[0] = shl( add( max_e, 2 ), 1 );
move16();
/* Step 4: Perform equalization */
FOR( chInIdx = 0; chInIdx < nchan_transport; chInIdx++ )
......@@ -1290,7 +1293,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
move16();
/*Compute Eq gains */
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx );
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy_fx[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain_fx );
FOR( binIdx = start; binIdx < stop; binIdx++ )
{
......@@ -1308,7 +1311,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx(
stop = shr( hLsSetUpConversion->sfbOffset[bandIdx + 1], 1 );
/*Compute Eq gains */
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], &dmxEnergy_fx[bandIdx], &eqGain_fx );
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy_fx[bandIdx], hLsSetUpConversion->te_prev_exp[0], &dmxEnergy_fx[bandIdx], hLsSetUpConversion->dmx_prev_exp[0], &eqGain_fx );
FOR( subFrameIdx = 0; subFrameIdx < NB_DIV; subFrameIdx++ )
......@@ -1481,23 +1484,32 @@ void ivas_lssetupconversion_process_param_mc_fx(
{
IF( channel_active[chOutIdx] )
{
Word16 te_scale = getScaleFactor32( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt );
scale_sig32( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt, te_scale );
Word16 dmx_sacle = getScaleFactor32( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt );
scale_sig32( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx], hLsSetUpConversion->sfbCnt, dmx_sacle );
Word16 te_max_e = s_max( sub( 50, shl( q_output, 1 ) ), sub( hLsSetUpConversion->te_prev_exp[chOutIdx], te_scale ) );
Word16 dmx_max_e = s_max( sub( 50, shl( q_output, 1 ) ), sub( hLsSetUpConversion->dmx_prev_exp[chOutIdx], dmx_sacle ) );
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
targetEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, targetEnergy[chOutIdx][bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx] ) );
targetEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( targetEnergy[chOutIdx][bandIdx], sub( te_max_e, sub( 50, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx], sub( te_max_e, sub( hLsSetUpConversion->te_prev_exp[chOutIdx], te_scale ) ) ) ) );
move32();
dmxEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, dmxEnergy[chOutIdx][bandIdx] ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] ) );
dmxEnergy[chOutIdx][bandIdx] = L_add( Mpy_32_32( LS_OUT_CONV_SMOOTHING_FACTOR_Q31, L_shr( dmxEnergy[chOutIdx][bandIdx], sub( dmx_max_e, sub( 50, shl( q_output, 1 ) ) ) ) ), Mpy_32_32( L_sub( ONE_IN_Q31, LS_OUT_CONV_SMOOTHING_FACTOR_Q31 ), L_shr( hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx], sub( dmx_max_e, sub( hLsSetUpConversion->dmx_prev_exp[chOutIdx], dmx_sacle ) ) ) ) );
move32();
hLsSetUpConversion->targetEnergyPrev_fx[chOutIdx][bandIdx] = targetEnergy[chOutIdx][bandIdx]; // Q0
move32();
hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] = dmxEnergy[chOutIdx][bandIdx]; // Q0
move32();
hLsSetUpConversion->te_prev_exp = 31;
}
hLsSetUpConversion->te_prev_exp[chOutIdx] = te_max_e; /* te_prev_exp = 50 - 2*q_output */
move16();
hLsSetUpConversion->dmx_prev_exp = 31;
hLsSetUpConversion->dmx_prev_exp[chOutIdx] = dmx_max_e; /* dmx_prev_exp = 50 - 2*q_output */
move16();
}
}
}
FOR( i = 0; i < outChannels; ++i )
{
......@@ -1517,7 +1529,7 @@ void ivas_lssetupconversion_process_param_mc_fx(
{
FOR( bandIdx = 0; bandIdx < hLsSetUpConversion->sfbCnt; bandIdx++ )
{
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[chOutIdx][bandIdx], &dmxEnergy[chOutIdx][bandIdx], &EQ ); // Q(EQ) = Q30
ivas_lssetupconversion_computeEQFactor_fx( &targetEnergy[chOutIdx][bandIdx], hLsSetUpConversion->te_prev_exp[chOutIdx], &dmxEnergy[chOutIdx][bandIdx], hLsSetUpConversion->dmx_prev_exp[chOutIdx], &EQ ); // Q(EQ) = Q30
Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx] = Mpy_32_32( L_shl( Cldfb_RealBuffer_InOut[chOutIdx][slotIdx][bandIdx], 1 ), EQ );
move32();
Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx] = Mpy_32_32( L_shl( Cldfb_ImagBuffer_InOut[chOutIdx][slotIdx][bandIdx], 1 ), EQ );
......
......@@ -397,7 +397,7 @@ UWord16 rc_uni_dec_read_bits(
FOR( tmp = range; tmp <= low; tmp += range )
{
val = add( val, 1 );
val = UL_addNsD( val, 1 );
}
/* in case of bitstream errors it is possible that val >= (1 << bits) */
......
......@@ -38,6 +38,7 @@
#include "prot.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#include <math.h>
......
......@@ -37,6 +37,7 @@
#include "prot_fx.h"
#include "ivas_prot.h"
#include "ivas_prot_fx.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_com_fx.h"
#include "ivas_rom_dec.h"
......
......@@ -39,6 +39,7 @@
#include "string.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include "ivas_rom_dec.h"
#include "ivas_stat_com.h"
......
......@@ -448,9 +448,9 @@ static void stereo_dft_dequantize_res_gains_fx(
FOR( i = 0; i < N; i++ )
{
/* Ensure the indices are within range -- may go out of range due to frame loss */
ind1[i] = check_bounds_s( ind1[i], 0, 30 ); /* Q0 */
ind1[i] = check_bounds_s_fx( ind1[i], 0, 30 ); /* Q0 */
move16();
ind2[i] = check_bounds_s( ind2[i], 0, 7 ); /* Q0 */
ind2[i] = check_bounds_s_fx( ind2[i], 0, 7 ); /* Q0 */
move16();
IF( LE_16( ind1[i], 15 ) )
{
......
......@@ -32,11 +32,12 @@
#include <assert.h>
#include <stdint.h>
#include "options.h"
#include <math.h>
#include "options.h"
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
#include "prot_fx.h"
#include "ivas_prot_fx.h"
......
......@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <assert.h>
#include "options.h"
#include "wmc_auto.h"
#include "basop_util.h"
......
......@@ -40,6 +40,7 @@
#include "options.h"
#include "jbm_pcmdsp_window.h"
#include "cnst.h"
#include "basop_util.h"
#include "wmc_auto.h"
/*-----------------------------------------------------------------------*
......
......@@ -29,22 +29,25 @@
the United Nations Convention on Contracts on the International Sales of Goods.
*******************************************************************************************************/
#include "lib_dec.h"
#include <math.h>
#include <assert.h>
#include <string.h>
#include "ivas_cnst.h"
#include "ivas_prot.h"
#include "ivas_prot_rend.h"
#include "prot.h"
#include "ivas_prot_fx.h"
#include "prot_fx.h"
#include "jbm_jb4sb.h"
#include "jbm_pcmdsp_apa.h"
#include "jbm_pcmdsp_fifo.h"
#include <math.h>
#include <assert.h>
#include <string.h>
#include "wmc_auto.h"
#define INV_1000_Q31 2147484 /*1/1000 IN Q31*/
/*---------------------------------------------------------------------*
* Local structs
*---------------------------------------------------------------------*/
......
......@@ -37,6 +37,7 @@
#include <stdint.h>
#include "options.h"
#include "cnst.h"
#include "typedef.h"
#include "wmc_auto.h"
/* clang-format off */
......
......@@ -40,6 +40,7 @@
#include <stdint.h>
#include "options.h"
#include "cnst.h"
#include "typedef.h"
extern const Word16 h_low_fx[5]; // Q15
extern const Word16 inv_sqi[15]; // Q15
......
......@@ -473,11 +473,11 @@ Word16 swb_bwe_dec_fx32(
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl, st_fx->element_mode );
SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl );
}
ELSE
{
SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl, st_fx->element_mode );
SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, yerror_fx, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx, &hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl );
}
test();
......
......@@ -1071,13 +1071,12 @@ Word16 swb_bwe_dec_fx( /*o :Q_syn_hb*/
IF( EQ_16( st_fx->L_frame, L_FRAME16k ) )
{
SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, ysynth_32, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx,
&hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl, st_fx->element_mode );
&hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 80, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl );
}
ELSE
{
SWB_BWE_decoding_fx( ysynth_fx, SWB_fenv_fx, ysynth_32, L_FRAME32k - 80, mode, &frica_flag, &hBWE_FD->prev_Energy_fx, st_fx->prev_SWB_fenv_fx,
&hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn,
st_fx->last_extl, st_fx->element_mode );
&hBWE_FD->prev_L_swb_norm, st_fx->tilt_wb_fx, &hBWE_FD->Seed, 6, &hBWE_FD->prev_weight_fx, st_fx->extl, Q_syn, st_fx->last_extl );
}
test();
......
......@@ -962,8 +962,6 @@ ivas_error acelp_core_enc(
update_average_rate_fx( st->hSC_VBR, st->core_brate );
}
}
st->prev_Q_new = Q_new;
move16();
pop_wmops();
return error;
......
......@@ -409,12 +409,8 @@ static void find_enr_dft_fx(
tmp_fx = L_add( tmp_fx, band_fx[i] ); // Qout
}
*Etot_fx = tmp_fx;
// To Be Checked
Scale_sig32( band_fx, NB_BANDS, 2 );
// To Be Checked
Scale_sig32( band_ener_fx, NB_BANDS, 2 );
move32();
return;
}
/*-------------------------------------------------------------------*
......@@ -573,18 +569,18 @@ void ivas_analy_sp_fx_front(
const Word32 input_Fs, /* i : input sampling rate */
Word16 *speech, /* i : speech buffer Q_new - preemph_bits */
const Word16 Q_new, /* i : current scaling exp Q0 */
Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE */
Word32 *fr_bands, /* o : energy in critical frequency bands Q_new + QSCALE - 2 */
Word32 *lf_E, /* o : per bin E for first... Q_new + QSCALE - 2 */
Word16 *Etot, /* o : total input energy Q8 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE */
const Word32 e_min_scaled, /* i : minimum energy scaled Q_new + QSCALE - 2 */
Word16 Scale_fac[2], /* o : FFT scales factors (2 values by frame) Q0 */
Word32 *Bin_E, /* o : per-bin energy spectrum Q7 */
Word32 *Bin_E_old, /* o : per-bin energy spectrum of the previous frame Q7 */
Word32 *PS, /* o : per-bin energy spectrum Q_new + QSCALE - 2 */
Word16 *EspecdB, /* o : per-bin log energy spectrum (with f=0) Q7 */
Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE)*/
Word32 *band_energies, /* o : energy in critical frequency bands without minimum noise floor MODE2_E_MIN (Q_new + QSCALE - 2)*/
Word16 *fft_buff /* o : FFT coefficients (Q_new + Scale_fac[i_subfr]) */
)
{
......@@ -594,6 +590,7 @@ void ivas_analy_sp_fx_front(
Word32 Ltmp, LEtot;
Word16 *pt_fft;
Word32 temp32_log;
Word16 max_pfft;
/*-----------------------------------------------------------------*
* Compute spectrum
* find energy per critical frequency band and total energy in dB
......@@ -632,8 +629,13 @@ void ivas_analy_sp_fx_front(
move16();
}
Scale_fac[i_subfr] = -2;
maximum_abs_16_fx( pt_fft, L_FFT, &max_pfft );
IF( max_pfft > 0 )
{
Scale_fac[i_subfr] = sub( norm_s( max_pfft ), LOG2_L_FFT );
move16();
}
Scale_sig( pt_fft, L_FFT, Scale_fac[i_subfr] );
/* compute the spectrum */
......@@ -653,8 +655,8 @@ void ivas_analy_sp_fx_front(
move16();
IF( LEtot != 0 )
{
/* Q of LEtot is Q_new + Q_SCALE - 1, LEtot / 2 can be considered as LEtot in Q_new + Q_SCALE - 2*/
temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q2 ) ) ); // Q25
/* Q of LEtot is Q_new + Q_SCALE - 1, LEtot / 2 can be considered as LEtot in Q_new + Q_SCALE - 1*/
temp32_log = BASOP_Util_Log10( LEtot, sub( Q31, add( Q_new, QSCALE - Q1 ) ) ); // Q25
temp32_log = Mpy_32_32( temp32_log, 1342177280 /* 10.f in Q27 */ ); // (Q25, Q27) -> Q21
*Etot = extract_l( L_shr( temp32_log, Q21 - Q8 ) ); // Q8
move16();
......@@ -665,6 +667,7 @@ void ivas_analy_sp_fx_front(
Word16 Qout = add( Q_new, QSCALE - 2 );
find_enr_dft_fx( hCPE, input_Fs, hCPE->hStereoDft->DFT_fx[0], pt_bands, lf_E, &LEtot, min_band, max_band, Bin_E, band_energies, sub( Q31, hCPE->hStereoDft->DFT_fx_e[0] ), &Qout );
scale_sig32( lf_E, VOIC_BINS, sub( add( Q_new, QSCALE - 2 ), Qout ) );
scale_sig32( Bin_E, ( L_FFT / 2 ), sub( add( Q_new, QSCALE - 2 ), Qout ) );
MVR2R_WORD32( lf_E, lf_E + VOIC_BINS, VOIC_BINS );
MVR2R_WORD32( Bin_E, Bin_E + ( L_FFT / 2 ), L_FFT / 2 );
MVR2R_WORD32( band_energies, band_energies + NB_BANDS, NB_BANDS );
......@@ -808,7 +811,7 @@ static void ivas_find_enr(
move16();
Ltmp1 = L_deposit_l( 0 );
FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
FOR( ; freq <= crit_bands_fx[i]; freq += BIN_FREQ_FX )
{
/*ptE = *ptR * *ptR + *ptI * *ptI */ /* energy */
Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
......@@ -896,7 +899,7 @@ static void ivas_find_enr(
move16();
Ltmp1 = L_deposit_l( 0 );
FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
FOR( ; freq <= crit_bands_fx[i]; freq += BIN_FREQ_FX )
{
/* *ptE = *ptR * *ptR + *ptI * *ptI */
Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) );
......@@ -990,16 +993,16 @@ static void ivas_find_enr(
static void ivas_find_enr1(
Word16 data[], /* i : fft result */
Word16 q_data, /* i : Q of fft result */
Word32 band[], /* o : per band energy Q_new + QSCALE */
Word32 band[], /* o : per band energy Q_new + QSCALE-2 */
Word32 *ptE, /* o : per bin energy for low frequencies Q_new + QSCALE-2 */
Word32 *LEtot, /* o : total energy Q_new + QSCALE-1 */
Word32 *LEtot, /* o : total energy Q_new + QSCALE-2 */
const Word16 min_band, /* i : minimum critical band Q0 */
const Word16 max_band, /* i : maximum critical band Q0 */
const Word16 Q_new, /* i : scaling factor Q0 */
const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE */
const Word32 e_min, /* i : minimum energy scaled Q_new + QSCALE-2 */
Word32 *Bin_E, /* o : Per bin energy Q_new + QSCALE-2 */
Word16 BIN_FREQ_FX, /* i : Number of frequency bins */
Word32 *band_energies /* o : per band energy without MODE2_E_MIN */
Word32 *band_energies /* o : per band energy without MODE2_E_MIN Q_new + QSCALE-2 */
)
{
Word16 i, cnt;
......@@ -1033,7 +1036,7 @@ static void ivas_find_enr1(
move32();
cnt = 0;
move16();
WHILE( freq <= crit_bands[i] )
WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
// *ptE = *ptR * *ptR + *ptI * *ptI; /* energy */
Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
......@@ -1048,7 +1051,7 @@ static void ivas_find_enr1(
*Bin_E++ = *ptE; // Q_new + QSCALE - 2
move32();
band[i] = L_add( band[i], *ptE++ ); // Q_new + QSCALE - 2
band[i] = L_add_sat( band[i], *ptE++ ); // Q_new + QSCALE - 2
move32();
ptR++;
ptI--;
......@@ -1057,16 +1060,15 @@ static void ivas_find_enr1(
cnt = add( cnt, 1 );
}
Ltmp = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
band[i] = L_shl( Ltmp, Q2 ); // Q_new + QSCALE
band[i] = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
move32();
band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE
band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE - 2
move32();
if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE
if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE - 2
{
band[i] = e_min; // Q_new + QSCALE
band[i] = e_min; // Q_new + QSCALE - 2
move32();
}
}
......@@ -1083,7 +1085,7 @@ static void ivas_find_enr1(
move32();
cnt = 0;
move16();
WHILE( freq <= crit_bands[i] )
WHILE( LE_32( freq, crit_bands_fx[i] ) )
{
// *Bin_E = *ptR * *ptR + *ptI * *ptI;
Word64 te = ( W_add( W_mult0_32_32( *ptR, *ptR ), W_mult0_32_32( *ptI, *ptI ) ) ); // 2 * Qfft
......@@ -1096,7 +1098,7 @@ static void ivas_find_enr1(
*Bin_E = L_shl( Ltmp, sub( add( Q_new, QSCALE - 2 ), add( shl( q_data, Q1 ), sub( te_exp, 32 ) ) ) ); // Q_new + QSCALE - 2
move32();
band[i] = L_add( band[i], *Bin_E++ ); // Q_new + QSCALE - 2
band[i] = L_add_sat( band[i], *Bin_E++ ); // Q_new + QSCALE - 2
move32();
ptR++;
ptI--;
......@@ -1105,16 +1107,15 @@ static void ivas_find_enr1(
cnt = add( cnt, 1 );
}
Ltmp = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
band[i] = L_shl( Ltmp, Q2 ); // Q_new + QSCALE
band[i] = Mpy_32_16_1( band[i], inv_tbl_fx[cnt] ); /* normalization per frequency bin */ // Q_new + QSCALE - 2
move32();
band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE
band_energies[i] = band[i]; /* per band energy without E_MIN */ // Q_new + QSCALE - 2
move32();
if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE
if ( LT_32( band[i], e_min ) ) // Q_new + QSCALE - 2
{
band[i] = e_min; // Q_new + QSCALE
band[i] = e_min; // Q_new + QSCALE - 2
move32();
}
}
......@@ -1128,7 +1129,7 @@ static void ivas_find_enr1(
move32();
FOR( i = min_band; i <= max_band; i++ )
{
etot = L_add_sat( etot, L_shr( band[i], Q1 ) ); // Q_new + QSCALE - 1
etot = L_add_sat( etot, band[i] ); // Q_new + QSCALE - 2
}
*LEtot = etot;
move32();
......@@ -1201,7 +1202,7 @@ static void find_enr(
move16();
Ltmp1 = L_deposit_l( 0 );
FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
FOR( ; LE_32( freq, crit_bands_fx[i] ); freq += BIN_FREQ_FX )
{
/*ptE = *ptR * *ptR + *ptI * *ptI */ /* energy */
Ltmp = L_mult( *ptI, *ptI );
......@@ -1286,7 +1287,7 @@ static void find_enr(
move16();
Ltmp1 = L_deposit_l( 0 );
FOR( ; freq <= crit_bands[i]; freq += BIN_FREQ_FX )
FOR( ; LE_32( freq, crit_bands_fx[i] ); freq += BIN_FREQ_FX )
{
/* *ptE = *ptR * *ptR + *ptI * *ptI */
Ltmp = L_mult( *ptI, *ptI );
......