Skip to content
......@@ -47,47 +47,6 @@
* Estimation of pitch-synchronous (voiced sounds) or half-frame energy
*----------------------------------------------------------------------------------*/
#ifndef IVAS_FLOAT_FIXED
void fer_energy(
const int16_t L_frame, /* i : frame length */
const int16_t clas, /* i : frame classification */
const float *synth, /* i : synthesized speech at Fs = 12k8 Hz */
const float pitch, /* i : pitch period */
float *enr, /* o : pitch-synchronous or half_frame energy */
const int16_t offset /* i : speech pointer offset (0 or L_frame) */
)
{
int16_t len;
const float *pt_synth;
if ( clas == VOICED_CLAS || clas == ONSET || clas == SIN_ONSET ) /* Voiced or Onset current frame */
{
len = (int16_t) ( pitch + 0.5f ); /* pitch value */
pt_synth = synth;
if ( offset != 0 )
{
pt_synth = synth + L_frame - len;
}
emaximum( pt_synth, len, enr ); /* pitch synchronous E */
}
else
{
pt_synth = synth;
if ( offset != 0 )
{
pt_synth = synth + L_frame / 2;
}
*enr = dotp( pt_synth, pt_synth, L_frame / 2 );
*enr /= (float) ( L_frame / 2 );
}
return;
}
#endif
#ifdef IVAS_FLOAT_FIXED
void fer_energy_fx(
const Word16 L_frame, /* i : frame length */
const Word16 clas, /* i : frame classification */
......@@ -143,50 +102,6 @@ void fer_energy_fx(
}
return;
}
#endif // IVAS_FLOAT_FIXED
#ifndef IVAS_FLOAT_FIXED
/*------------------------------------------------------------------------*
* frame_energy()
*
* Compute pitch-synchronous energy at the frame end
*------------------------------------------------------------------------*/
float frame_energy(
const int16_t L_frame, /* i : length of the frame */
const float *pitch, /* i : pitch values for each subframe */
const float *speech, /* i : pointer to speech signal for E computation */
const float lp_speech, /* i : long-term active speech energy average */
float *frame_ener /* o : pitch-synchronous energy at frame end */
)
{
float enern;
const float *pt1;
int16_t len;
float dotProd;
len = (int16_t) ( 0.5f * ( pitch[2] + pitch[3] ) + 0.5f );
if ( len < L_SUBFR )
{
len *= 2;
}
pt1 = speech + L_frame - len;
dotProd = dotp( pt1, pt1, len );
if ( 0 == dotProd )
{
*frame_ener = MIN_LOG_VAL_60dB;
}
else
{
*frame_ener = 10.0f * (float) log10( dotProd / (float) len );
}
enern = *frame_ener - lp_speech;
return enern;
}
#endif
/*----------------------------------------------------------------------------------*
* frame_ener()
......
......@@ -46,34 +46,6 @@
*
*----------------------------------------------------------------------------------*/
#ifndef IVAS_FLOAT_FIXED
/*! r: codebook gain (adaptive or fixed) */
float get_gain_flt(
const float x[], /* i : target signal */
const float y[], /* i : filtered codebook excitation */
const int16_t n, /* i : segment length */
float *en_y /* o : energy of y (sum of y[]^2, optional) */
)
{
float corr = 0.0f, ener = 1e-6f;
int16_t i;
for ( i = 0; i < n; i++ )
{
corr += x[i] * y[i];
ener += y[i] * y[i];
}
if ( en_y )
{
*en_y = ener;
}
return ( corr / ener );
}
#endif
#ifdef IVAS_FLOAT_FIXED
Word32 get_gain( /* output: codebook gain (adaptive or fixed) Q16 */
const Word16 x[], /* input : target signal Qx */
const Word16 y[], /* input : filtered codebook excitation Qx */
......@@ -178,4 +150,3 @@ Word32 get_gain2( /* output: codebook gain (adaptive or fixed)
return Lgain;
}
#endif
This diff is collapsed.
......@@ -1007,7 +1007,7 @@ static Word16 Find_bit_alloc_IVAS_fx( /*o: Number
/*nb_bands_max = (int16_t)(nb_bands_max * nb_bands_adj + 0.5f);*/
nb_bands_max = round_fx( Mpy_32_16_1( L_shl( nb_bands_adj, 5 ), shl( nb_bands_max, 10 - 2 ) ) ); /* Q0 */
nb_bands_max = check_bounds_s( nb_bands_max, 5, nb_tot_bands_in );
nb_bands_max = check_bounds_s_fx( nb_bands_max, 5, nb_tot_bands_in );
/* bit_fracf *= SWB_bit_budget;*/
......
This diff is collapsed.
This diff is collapsed.
......@@ -48,106 +48,10 @@
*-------------------------------------------------------------------*/
#define ATT_LENGHT16k 80
#ifndef IVAS_FLOAT_FIXED
#define INV_L_FRAME16k ( 1.0f / L_FRAME16k )
#endif
#define ATT_LENGHT 64
#define ATT_SEG_LEN ( L_FRAME / ATT_LENGHT )
#ifndef IVAS_FLOAT_FIXED
#define INV_ATT_SEG_LEN ( 1.0f / ATT_SEG_LEN )
#define INV_L_FRAME ( 1.0f / L_FRAME )
#endif
#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
* pre_echo_att()
*
* Attenuation of the pre-echo when encoder specifies an attack
*-------------------------------------------------------------------*/
void pre_echo_att(
float *Last_frame_ener, /* i/o: Energy of the last frame */
float *exc, /* i/o: Excitation of the current frame */
const int16_t attack_flag, /* i : attack flag (GSC or TC) */
const int16_t last_coder_type, /* i : Last coder type */
const int16_t L_frame /* i : frame length */
)
{
float etmp;
float etmp1;
float finc[ATT_LENGHT16k], ratio_float, inv_l_frame;
int16_t att_len;
int16_t attack_pos, i;
if ( attack_flag > 0 && last_coder_type == AUDIO )
{
/*-------------------------------------------------------------------------*
* Find where the onset (attack) occurs by computing the energy per section
* The inverse weighting aims to favor the first maxima in case of
* gradual onset
*-------------------------------------------------------------------------*/
att_len = ATT_LENGHT;
if ( L_frame == L_FRAME16k )
{
att_len = ATT_LENGHT16k;
}
for ( i = 0; i < att_len; i++ )
{
finc[i] = sum2_f( exc + i * ATT_SEG_LEN, ATT_SEG_LEN ) * ( (float) ( att_len - i ) / ( att_len ) );
}
etmp = -1;
attack_pos = maximum( finc, att_len, &etmp );
/* Scaled the maximum energy and allowed 6 dB increase*/
etmp *= INV_ATT_SEG_LEN;
etmp1 = etmp;
*Last_frame_ener *= 4.0f;
/* If the maximum normalized energy > last frame energy + 6dB */
if ( etmp > *Last_frame_ener && attack_pos > 0 )
{
/* Find the average energy before the attack */
etmp = sum_f( finc, attack_pos ) + 0.01f;
etmp /= ( attack_pos * ATT_SEG_LEN );
/* Find the correction factor and apply it before the attack */
ratio_float = (float) sqrt( *Last_frame_ener / etmp );
/* Pre-echo atttenuation should never increase the energy */
ratio_float = min( ratio_float, 1.0f );
for ( i = 0; i < attack_pos * ATT_SEG_LEN; i++ )
{
exc[i] *= ratio_float;
}
}
*Last_frame_ener = etmp1;
}
else
{
/*-------------------------------------------------------*
* In normal cases, just compute the energy of the frame
*-------------------------------------------------------*/
etmp = sum2_f( exc, L_frame ) + 0.01f;
inv_l_frame = INV_L_FRAME;
if ( L_frame == L_FRAME16k )
{
inv_l_frame = INV_L_FRAME16k;
}
etmp *= inv_l_frame;
*Last_frame_ener = etmp;
}
return;
}
#endif
#ifdef IVAS_FLOAT_FIXED
#ifdef IVAS_FLOAT_FIXED
void pre_echo_att_fx(
Word32 *Last_frame_ener_fx, /* i/o: Energy of the last frame 2*Q_new+1*/
Word16 *exc_fx, /* i/o: Excitation of the current frame Q_new*/
......@@ -271,7 +175,6 @@ void pre_echo_att_fx(
return;
}
#endif
void pre_echo_att_ivas_fx(
......@@ -398,4 +301,3 @@ void pre_echo_att_ivas_fx(
return;
}
#endif
......@@ -51,90 +51,8 @@
* void
*/
#ifndef IVAS_FLOAT_FIXED
void hp20_flt(
Float32 signal[],
const Word16 lg,
Float32 mem[],
const Word32 Fs )
{
Word16 i;
Float32 x0, x1, x2, y0, y1, y2;
Float32 a1, a2, b1, b2;
y1 = mem[0];
y2 = mem[1];
x0 = mem[2];
x1 = mem[3];
if ( Fs == 8000 )
{
/* hp filter 20Hz at 3dB for 8000KHz input sampling rate
[b,a] = butter(2, 20.0/4000.0, 'high');
b = [0.988954248067140 -1.977908496134280 0.988954248067140]
a =[1.000000000000000 -1.977786483776764 0.978030508491796]*/
a1 = 1.977786483776764f;
a2 = -0.978030508491796f;
b1 = -1.977908496134280f;
b2 = 0.988954248067140f;
}
else if ( Fs == 16000 )
{
/* hp filter 20Hz at 3dB for 16000KHz sampling rate
[b,a] = butter(2, 20.0/8000.0, 'high');
b =[ 0.994461788958195 -1.988923577916390 0.994461788958195]
a =[1.000000000000000 -1.988892905899653 0.988954249933127] */
a1 = 1.988892905899653f;
a2 = -0.988954249933127f;
b1 = -1.988923577916390f;
b2 = 0.994461788958195f;
}
else if ( Fs == 32000 )
{
/* hp filter 20Hz at 3dB for 32000KHz sampling rate
[b,a] = butter(2, 20.0/16000.0, 'high');
b =[0.997227049904470 -1.994454099808940 0.997227049904470]
a =[1.000000000000000 -1.994446410541927 0.994461789075954]*/
a1 = 1.994446410541927f;
a2 = -0.994461789075954f;
b1 = -1.994454099808940f;
b2 = 0.997227049904470f;
}
else
{
/* hp filter 20Hz at 3dB for 48000KHz sampling rate
[b,a] = butter(2, 20.0/24000.0, 'high');
b =[ 0.998150511190452 -1.996301022380904 0.998150511190452]
a =[1.000000000000000 -1.996297601769122 0.996304442992686]*/
a1 = 1.996297601769122f;
a2 = -0.996304442992686f;
b1 = -1.996301022380904f;
b2 = 0.998150511190452f;
}
for ( i = 0; i < lg; i++ )
{
x2 = x1;
x1 = x0;
x0 = signal[i];
y0 = ( y1 * a1 ) + ( y2 * a2 ) + ( x0 * b2 ) + ( x1 * b1 ) + ( x2 * b2 );
signal[i] = y0;
y2 = y1;
y1 = y0;
}
mem[0] = ( ( y1 > 1e-10 ) | ( y1 < -1e-10 ) ) ? y1 : 0;
mem[1] = ( ( y2 > 1e-10 ) | ( y2 < -1e-10 ) ) ? y2 : 0;
mem[2] = ( ( x0 > 1e-10 ) | ( x0 < -1e-10 ) ) ? x0 : 0;
mem[3] = ( ( x1 > 1e-10 ) | ( x1 < -1e-10 ) ) ? x1 : 0;
return;
}
#endif
#define HP20_COEFF_SCALE ( 2 )
#ifdef IVAS_FLOAT_FIXED
/*
* hp20
*
......@@ -797,4 +715,3 @@ void hp20_fx_32(
return;
}
#endif
#endif
......@@ -35,7 +35,6 @@
#include "prot_fx.h"
#include "oper_32b.h"
#include "move.h"
#include "count.h"
/*--------------------------------------------------------------------------*
* hq2_noise_inject()
......
......@@ -36,6 +36,7 @@
#include <stdint.h>
#include "options.h"
#include "cnst.h"
#include "typedef.h"
/* clang-format off */
......@@ -1389,7 +1390,8 @@ typedef enum
#define MCMASA_LFE_THETA_Q14 (21299) // Q14
#define MCMASA_LFE_QLOW_Q12 (-26624) // Q12
#define MCMASA_LFE_DELTA_Q11 (2048) // Q11
#define MCMASA_LFE_QLOW_Q11 (-13312) // Q11
#define MCMASA_LFE_DELTA_Q10 (1024) // Q10
#define NUM_ELEVATED_SPEAKERS 4
#define MCMASA_MIN_SPEAKERS_SEPARATE_CENTER 4
......
......@@ -1480,14 +1480,16 @@ void calculate_hodirac_sector_parameters_fx(
tmp16 = BASOP_util_atan2( *p_sec_I_vec_smth_y_fx, *p_sec_I_vec_smth_x_fx, sub( *p_sec_I_vec_smth_y_exp, *p_sec_I_vec_smth_x_exp ) ); // Q13
*p_azi_fx = Mpy_32_32( L_deposit_h( tmp16 ), _180_OVER_PI_Q25 ); // (Q13 + 16) + Q25 - 31 = 54 - 31 = Q23
tmp16 = BASOP_util_atan2( *p_sec_I_vec_smth_z_fx, tmp_xy_hypo, sub( *p_sec_I_vec_smth_z_exp, tmp_e ) ); // Q13
move32();
tmp16 = BASOP_util_atan2( *p_sec_I_vec_smth_z_fx, L_add( tmp_xy_hypo, EPSILON_FX_SMALL ), sub( *p_sec_I_vec_smth_z_exp, tmp_e ) ); // Q13
*p_ele_fx = Mpy_32_32( L_deposit_h( tmp16 ), _180_OVER_PI_Q25 ); // (Q13 + 16) + Q25 - 31 = 54 - 31 = Q23
move32();
*p_ene_fx = *p_energy_smth_fx;
move32();
*p_ene_exp = *p_energy_smth_exp;
move16();
tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, *p_energy_smth_fx, &tmp_e ) );
tmp32 = L_deposit_h( BASOP_Util_Divide3232_Scale( normI_fx, L_add( *p_energy_smth_fx, EPSILON_FX_SMALL ), &tmp_e ) );
tmp_e = add( tmp_e, sub( normI_exp, *p_energy_smth_exp ) );
tmp32 = BASOP_Util_Add_Mant32Exp( ONE_IN_Q30, 1, L_negate( tmp32 ), tmp_e, &tmp_e );
*p_diff_fx = tmp32;
......@@ -1500,16 +1502,17 @@ void calculate_hodirac_sector_parameters_fx(
move32();
tmp_diff_exp = *p_diff_exp;
move16();
if ( tmp_diff_fx < 0 )
{
tmp_diff_fx = 0;
move32();
}
tmp_diff_fx = L_shr( tmp_diff_fx, sub( 2, tmp_diff_exp ) ); // Q29
tmp_diff_exp = 2;
move16();
IF( tmp_diff_fx < 0 )
{
*p_diff_fx = 0;
move32();
}
IF( GT_32( tmp_diff_fx, ( ONE_IN_Q29 / 2 ) ) )
IF( GT_32( tmp_diff_fx, ONE_IN_Q28 ) )
{
IF( hDirAC->firstrun_sector_params )
{
......
......@@ -31,12 +31,13 @@
*******************************************************************************************************/
#include <stdint.h>
#include "options.h"
#include <assert.h>
#include <math.h>
#include "options.h"
#include "prot.h"
#include "ivas_prot.h"
#include "rom_com.h"
#include "ivas_rom_com.h"
#include <assert.h>
#include "wmc_auto.h"
#include "ivas_prot_fx.h"
#include "prot_fx.h"
......@@ -743,6 +744,7 @@ void ivas_fb_mixer_process_fx(
const Word32 *pFilterbank_bin_to_band_re_fx;
const Word32 *pFilterbank_bin_to_band_im_fx;
Word16 q_pMdft_out_fx[2];
Word32 *pMdft_out_fx[2];
Word32 *pOut_fr_re_fx, *pOut_fr_im_fx;
Word16 q_pOut_fr_fx = 31;
......@@ -837,11 +839,17 @@ void ivas_fb_mixer_process_fx(
move16();
}
}
Word16 scale = sub( s_min( L_norm_arr( pOut_fr_re_fx, frame_len ), L_norm_arr( pOut_fr_im_fx, frame_len ) ), find_guarded_bits_fx( shl( frame_len, 1 ) ) );
scale_sig32( pOut_fr_re_fx, frame_len, scale );
scale_sig32( pOut_fr_im_fx, frame_len, scale );
ivas_imdft_fx( pOut_fr_re_fx, pOut_fr_im_fx, pMdft_out_fx[hist], frame_len );
q_pMdft_out_fx[hist] = add( q_pOut_fr_fx, scale );
move16();
}
scale_sig32( pMdft_out_fx[0], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[0] ) );
scale_sig32( pMdft_out_fx[1], shl( frame_len, 1 ), sub( s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] ), q_pMdft_out_fx[1] ) );
ivas_fb_mixer_cross_fading_fx( hFbMixer, ppOut_pcm_fx, pMdft_out_fx[0], pMdft_out_fx[1], ch, frame_len, frame_len );
q_ppOut_pcm_fx[ch] = q_pOut_fr_fx;
q_ppOut_pcm_fx[ch] = s_min( q_pMdft_out_fx[0], q_pMdft_out_fx[1] );
move16();
}
......@@ -853,7 +861,6 @@ void ivas_fb_mixer_process_fx(
*
*
*-----------------------------------------------------------------------------------------*/
#ifdef IVAS_FLOAT_FIXED
void ivas_fb_mixer_get_in_out_mapping_fx(
const IVAS_FB_CFG *fb_cfg, /* i : FB config. handle */
Word16 in_out_mixer_map[IVAS_MAX_FB_MIXER_OUT_CH][IVAS_MAX_SPAR_FB_MIXER_IN_CH] /* i/o: mixing mapping */
......@@ -887,7 +894,6 @@ void ivas_fb_mixer_get_in_out_mapping_fx(
return;
}
#endif
/*-----------------------------------------------------------------------------------------*
* Function ivas_calculate_abs_fr()
......
......@@ -50,12 +50,6 @@
*-----------------------------------------------------------------------*/
#define BITS_ISM_INACTIVE ( BRATE_ISM_INACTIVE / FRAMES_PER_SEC )
#ifndef IVAS_FLOAT_FIXED
#define BETA_ISM_LOW_IMP 0.6f
#define BETA_ISM_MEDIUM_IMP 0.8f
#endif
#define BETA_ISM_LOW_IMP_Q31 ( 1288490189 ) // 0.6 in Q31
#define BETA_ISM_MEDIUM_IMP_Q31 ( 1717986918 ) // 0.8 in Q31
#define BETA_ISM_MEDIUM_IMP_BY_8_Q31 ( 214748365 ) // 0.8 in Q29
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.