Skip to content
......@@ -8,8 +8,5 @@ fi
make clean
make all -j 8
# get all modes except SBA rate switching (which is broken currently)
list=$(./scripts/runIvasCodec.py -l | grep -v "SBA.*rs")
./scripts/runIvasCodec.py -p ./scripts/config/ci_linux.json -m $list -U 1 | tee smoke_test_output.txt
./scripts/runIvasCodec.py -p ./scripts/config/ci_linux.json -m $list -U 1 -D="-fec 15" --decoder_only | tee smoke_test_output_plc.txt
./scripts/runIvasCodec.py -p ./scripts/config/ci_linux.json -U 1 | tee smoke_test_output.txt
./scripts/runIvasCodec.py -p ./scripts/config/ci_linux.json -U 1 -D="-fec 15" --decoder_only | tee smoke_test_output_plc.txt
......@@ -1820,7 +1820,7 @@ ivas_error preview_indices(
break;
}
}
else if ( total_brate == IVAS_SID_4k4 )
else if ( total_brate == IVAS_SID_5k2 )
{
/* read SID format */
st_ivas->sid_format = 0;
......@@ -1884,14 +1884,6 @@ ivas_error preview_indices(
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Invalid value %c found in SID format field.", st_ivas->sid_format );
}
}
else if ( total_brate == IVAS_SID_5k )
{
/* SBA SID frame */
st_ivas->sid_format = SID_SBA_1TC;
st_ivas->ivas_format = SBA_FORMAT;
st_ivas->sba_mode = SBA_MODE_SPAR;
st_ivas->element_mode_init = IVAS_SCE;
}
/* only read element mode from active frames */
if ( is_DTXrate( total_brate ) == 0 )
......@@ -1975,7 +1967,6 @@ ivas_error preview_indices(
}
else if ( st_ivas->ivas_format == SBA_FORMAT )
{
/* Read SBA planar flag and SBA order */
st_ivas->sba_planar = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA] == 1 );
st_ivas->sba_order = ( bit_stream[IVAS_FORMAT_SIGNALING_NBITS_SBA + 2] == 1 );
......@@ -1983,7 +1974,7 @@ ivas_error preview_indices(
st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( total_brate, st_ivas->sba_order );
ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ), st_ivas->sba_mode );
ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) );
}
}
......@@ -2062,17 +2053,9 @@ ivas_error read_indices(
st_ivas->element_mode_init = IVAS_SCE;
}
else if ( k == SIZE_IVAS_BRATE_TBL )
{
/*temp change for SPAR DTX*/
if ( total_brate == IVAS_SID_5k )
{
st_ivas->element_mode_init = -1;
}
else
{
return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error, illegal bitrate (%d) in the G.192 frame ! Exiting ! \n", total_brate );
}
}
else
{
st_ivas->element_mode_init = -1;
......@@ -2965,4 +2948,16 @@ void evs_dec_previewFrame(
}
void dtx_read_padding_bits(
DEC_CORE_HANDLE st,
int16_t num_bits )
{
/* TODO: temporary hack, need to decide what to do with core-coder bitrate */
int32_t tmp;
tmp = st->total_brate;
st->total_brate = st->total_brate + num_bits * FRAMES_PER_SEC;
get_next_indice( st, num_bits );
st->total_brate = tmp;
}
#undef WMC_TOOL_MAN
......@@ -132,6 +132,9 @@ enum{
#define MAX_V_MULT_MAT 100 /* maximum array length for the function v_mult_mat() */
#define SBA_AGC_FORCE_ENABLE 1
#define SBA_AGC_FORCE_DISABLE 0
#define SBA_AGC_DEFAULT -1
/*----------------------------------------------------------------------------------*
* Layers
......@@ -1019,6 +1022,7 @@ enum
#define SIZE_BK22_36b 128
#define SIZE_BK23_36b 64
/* Gain quantizer constants */
#define NB_QUA_GAIN5B 32 /* Number of quantization level */
#define NB_QUA_GAIN6B 64 /* Number of quantization level */
#define NB_QUA_GAIN7B 128 /* Number of quantization level */
......
......@@ -47,6 +47,9 @@
#define IVAS_MAX_NUM_OBJECTS 4
#define IVAS_MAX_OUTPUT_CHANNELS 16
#define IVAS_CLDFB_NO_CHANNELS_MAX ( 60 )
#ifdef EXT_RENDERER
#define IVAS_MAX_INPUT_LFE_CHANNELS 4
#endif
/*----------------------------------------------------------------------------------*
* Common API structures
......@@ -76,7 +79,11 @@ typedef struct _IVAS_ISM_METADATA
float gainFactor;
} IVAS_ISM_METADATA;
#ifdef EXT_RENDERER
typedef struct
#else
typedef struct _IVAS_QUATERNION
#endif
{
float w, x, y, z;
......
......@@ -165,7 +165,7 @@ int16_t get_codec_mode(
int16_t getTcxonly(
const int16_t element_mode, /* i : IVAS element mode */
const int32_t total_brate, /* i : total bitrate */
const int16_t is_mct /* i : MCT mode flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0)*/
)
{
int16_t tcxonly = 0;
......@@ -187,7 +187,7 @@ int16_t getTcxonly(
}
break;
case IVAS_CPE_MDCT:
if ( total_brate >= ( is_mct ? IVAS_32k : IVAS_48k ) )
if ( total_brate >= ( MCT_flag ? IVAS_32k : IVAS_48k ) )
{
tcxonly = 1;
}
......@@ -808,7 +808,7 @@ void init_tcx_cfg(
const int16_t infoIGFStopFreq,
const int16_t element_mode,
const int16_t ini_frame,
const int16_t is_mct,
const int16_t MCT_flag,
const MCT_CHAN_MODE mct_chan_mode /* i : MDCT channel mode */
)
{
......@@ -850,7 +850,7 @@ void init_tcx_cfg(
if ( hTcxCfg->fIsTNSAllowed )
{
InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, is_mct );
InitTnsConfigs( bwidth, hTcxCfg->tcx_coded_lines, hTcxCfg->tnsConfig, infoIGFStopFreq, total_brate, element_mode, MCT_flag );
SetAllowTnsOnWhite( hTcxCfg->tnsConfig, element_mode == IVAS_CPE_MDCT );
}
......
......@@ -90,10 +90,10 @@ void fill_spectrum(
const int16_t element_mode /* i : element mode */
)
{
float CodeBook[FREQ_LENGTH];
float CodeBook[L_SPEC48k_EXT];
int16_t cb_size = 0;
int16_t last_sfm;
float CodeBook_mod[FREQ_LENGTH];
float CodeBook_mod[L_SPEC48k_EXT];
float norm_adj[NB_SFM];
int16_t high_sfm = 23;
int16_t flag_32K_env_hangover;
......
......@@ -40,6 +40,7 @@
#endif
#include <math.h>
#include "wmops.h"
#include "prot.h"
/*------------------------------------------------------------------------------------------*
* Local constants
......@@ -47,6 +48,9 @@
#define SQRKMAX ( 1.5f )
#define NBITS_DIFFG ( 2 )
#define DBSTEP ( -6.f ) /* desired dB step value in dB*/
#define ABS_EMIN_MAX ( 3 )
#define MAXATTEXP ( 1 ) /* the desired maximum attenuation exponent range per frame*/
/*-----------------------------------------------------------------------------------------*
* Function ivas_agc_initWindowFunc()
......@@ -60,12 +64,14 @@ void ivas_agc_initWindowFunc(
{
int16_t i;
float N;
float a;
N = (float) ( length - 1 );
a = 0.5f * ( 1.f - powf( 10.f, DBSTEP / 20.f ) );
for ( i = 0; i < length; i++ )
{
pWinFunc[i] = 0.75f + 0.25f * cosf( EVS_PI * i / N );
pWinFunc[i] = 1.f + a * ( cosf( EVS_PI * i / N ) - 1.f );
}
return;
......@@ -89,7 +95,7 @@ void ivas_agc_calcGainParams(
nbits = NBITS_DIFFG;
*absEmin = (uint16_t) ceilf( logf( ceilf( SQRKMAX * numCoeffs ) ) * INV_LOG_2 );
*absEmin = max( ABS_EMIN_MAX, (uint16_t) ceilf( logf( ceilf( SQRKMAX * numCoeffs ) ) * INV_LOG_2 ) );
totExp = *absEmin + AGC_EMAX + 1;
*betaE = (uint16_t) ceilf( logf( totExp ) * INV_LOG_2 );
......@@ -98,10 +104,11 @@ void ivas_agc_calcGainParams(
if ( nbits > 0 )
{
Bm = NBITS_DIFFG;
Bm = min( AGC_BITS_PER_CH - 1, NBITS_DIFFG );
}
*maxAttExp = ( (uint16_t) powf( 2, Bm ) ) - 2;
*maxAttExp = min( MAXATTEXP, *maxAttExp );
return;
}
......
......@@ -107,6 +107,10 @@ typedef enum
AUDIO_CONFIG_ISM2, /* ISM2 */
AUDIO_CONFIG_ISM3, /* ISM3 */
AUDIO_CONFIG_ISM4, /* ISM4 */
#ifdef EXT_RENDERER /* TODO tmu : temporary, or use something like IVAS_ENC input format */
AUDIO_CONFIG_MASA1, /* MASA1 */
AUDIO_CONFIG_MASA2, /* MASA2 */
#endif
AUDIO_CONFIG_EXTERNAL /* external renderer */
} AUDIO_CONFIG;
......@@ -165,12 +169,10 @@ typedef enum
#define HEAD_ROTATION_HOA_ORDER 3 /* HOA 3rd order */
#define MAX_CICP_CHANNELS 16 /* max channels for loudspeaker layouts (16 for custom layouts)*/
#define MAX_OUTPUT_CHANNELS 16 /* Maximum number of output channels (HOA 3rd order) */
#define IVAS_MAX_NUM_CH 16 /* == MAX_OUTPUT_CHANNELS */
#define FOA_CHANNELS 4 /* number of FOA channels */
#define BINAURAL_CHANNELS 2 /* number of channels for binaural output configuration */
#define CPE_CHANNELS 2 /* number of CPE (stereo) channels */
#define FOA_CHANNELS 4 /* number of FOA channels */
#define MAX_NUM_OBJECTS 4 /* max. number of audio objects */
#define MAX_SCE MAX_NUM_OBJECTS /* max. number of SCEs */
......@@ -191,13 +193,17 @@ typedef enum
#define IVAS_MAX_SBA_ORDER 3 /* Maximum supported Ambisonics order */
#ifdef EXT_RENDERER
#define IVAS_LIMITER_THRESHOLD 32729 /* -0.01 dBFS */
#define IVAS_LIMITER_ATTACK_SECONDS 0.005f
#endif
#define IVAS_NUM_SUPPORTED_FS 3 /* number of supported sampling-rates in IVAS */
/*----------------------------------------------------------------------------------*
* IVAS Bitrates
*----------------------------------------------------------------------------------*/
#define IVAS_SID_4k4 4400 /* SID frame bitrate */
#define IVAS_SID_5k 5000 /* SBA SID frame bitrate */
#define IVAS_SID_5k2 5200 /* SID frame bitrate */
#define IVAS_13k2 13200
#define IVAS_16k4 16400
#define IVAS_24k4 24400
......@@ -215,8 +221,8 @@ typedef enum
#define IVAS_BRATE_MAX IVAS_512k
#define SIZE_IVAS_BRATE_TBL 17
#define IVAS_NUM_ACTIVE_BRATES (SIZE_IVAS_BRATE_TBL - 3)
#define SIZE_IVAS_BRATE_TBL 16
#define IVAS_NUM_ACTIVE_BRATES (SIZE_IVAS_BRATE_TBL - 2)
/*----------------------------------------------------------------------------------*
* IVAS modes : IVAS SCE, IVAS CPE modes (DFT, TD, MDCT stereo)
......@@ -803,17 +809,22 @@ enum fea_names
#define MAX_MDCT_ITD_BRATE IVAS_64k
#define SNS_LOW_BR_MODE -1
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
#define SNS_NPTS 16 /* Number of downsampled SNS parameters */
#define MDCT_ST_PLC_FADEOUT_START_FRAME 3
#define MDCT_ST_PLC_FADEOUT_MIN_NOISE_NRG 0.001f
#define MDCT_ST_PLC_FADEOUT_MAX_CONC_FRAME 2 * FRAMES_PER_SEC
#define MDCT_ST_PLC_FADEOUT_TO_ZERO_LEN 20
typedef enum {
EQUAL_CORES,
TCX10_IN_0_TCX20_IN_1,
TCX20_IN_0_TCX10_IN_1,
} TONALMDCTCONC_NOISE_GEN_MODE;
#endif
typedef enum {
ON_FIRST_LOST_FRAME,
ON_FIRST_GOOD_FRAME,
} TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE;
/*----------------------------------------------------------------------------------*
......@@ -829,17 +840,24 @@ typedef enum {
*----------------------------------------------------------------------------------*/
// VE: this should be renamed to e.g. N_SPATIAL_SUBFRAMES
#define MAX_PARAM_SPATIAL_SUBFRAMES 4 /* Maximum number of subframes for parameteric spatial coding */
#define L_SPATIAL_SUBFR_48k (L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES)
/*----------------------------------------------------------------------------------*
* SBA Constants
*----------------------------------------------------------------------------------*/
#define SBA_FOA_ORDER 1
#define SBA_HOA2_ORDER 2
#define SBA_HOA3_ORDER 3
#define SBA_PLANAR_BITS 1
#define SBA_ORDER_BITS 2
#define SBA_MIN_BRATE_HOA IVAS_256k
#define SBA_NHARM_HOA3 16
#define SBA_T_DESIGN_11_SIZE 70
#define SBA_DTX_BITRATE_THRESHOLD IVAS_80k
typedef enum
{
......@@ -853,13 +871,7 @@ typedef enum
* DirAC Constants
*----------------------------------------------------------------------------------*/
#define DIRAC_MAX_ANA_CHANS 4 /* Maximum number of channels for DirAC analysis */
#define DIRAC_MAX_TRANS_CHANS 8 /* Maximum number of transport channels for DirAC */
#define DIRAC_MIN_BITRATE_8_TRANS_CHAN IVAS_384k
#define DIRAC_MIN_BITRATE_6_TRANS_CHAN IVAS_256k
#define DIRAC_MIN_BITRATE_4_TRANS_CHAN IVAS_160k /* minimum bitrate for sending 4 transport channels (FOA) */
#define DIRAC_MIN_BITRATE_2_TRANS_CHAN IVAS_48k /* minimum bitrate for sending 2 transport channels (Stereo) */
#define DIRAC_MAX_ANA_CHANS FOA_CHANNELS /* Maximum number of channels for DirAC analysis */
#define DIRAC_NUM_DIMS 3 /* number of directions to estimate (X,Y,Z) */
#define DIRAC_MAX_NBANDS 12 /* Maximum number of frequency bands for the DirAC Side Parameter decoding */
......@@ -926,7 +938,7 @@ typedef enum
#define SPAR_CONFIG_BW FB
#define IVAS_SPAR_MAX_CH (2*IVAS_MAX_SBA_ORDER + 2) /* FOA + planar HOA */
#define IVAS_SPAR_MAX_CH (FOA_CHANNELS + 2 * ( IVAS_MAX_SBA_ORDER - 1 )) /* FOA + planar HOA */
#define IVAS_SPAR_P_LOWERTRI ((IVAS_SPAR_MAX_CH - 1) * (IVAS_SPAR_MAX_CH - 2)) >> 1
#define IVAS_SPAR_MAX_C_COEFF (IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS) * ( IVAS_SPAR_MAX_DMX_CHS - 1)
......@@ -1008,9 +1020,9 @@ enum
#define IVAS_DECORR_PARM_LOOKAHEAD_TAU 2e-3f
#define IVAS_DECORR_PARM_APD_TAU 20e-3f
/* IVAS PCA */
/* IVAS SBA PCA */
#define IVAS_PCA_NB_SUBR 20 /* 80 -> 0.25 ms, 40 -> 0.5 ms... */
#define IVAS_PCA_COV_THRES 1e-9f
#define IVAS_PCA_COV_THRES 3e-5f
#define IVAS_PCA_QUAT_EPS 1e-7f
#define IVAS_PCA_QBITS 19
#define IVAS_PCA_N1 91
......@@ -1329,7 +1341,7 @@ typedef enum
#define PANNING_ELE_RESOLUTION 5
#define EFAP_MAX_CHAN_NUM 5 /* Maximum number of channels that constitute a polygon, 4 or 5 */
#define EFAP_MAX_POLY_SET 70 /* Upper bound on number of polygons; with a Speaker setup of 26.0, we obtain 54 polygons/triangles in the matlab implementation. */
#define EFAP_MAX_POLY_SET 50 /* Upper bound on number of polygons; with a Speaker setup of 16.0, we obtain 44 polygons/triangles in the matlab implementation. */
#define EFAP_MODE_EFAP 0 /* EFAP Panning */
#define EFAP_MODE_EFIP 1 /* EFIP Panning */
......@@ -1361,12 +1373,21 @@ typedef enum
#define BINAURAL_COHERENCE_DIFFERENCE_BINS 9 /* Number of bins for direction-dependent diffuse-field binaural coherence */
#ifdef EXT_RENDERER
#define HEADROT_ORDER 3
#define HEADROT_SHMAT_DIM ( ( HEADROT_ORDER + 1 ) * ( HEADROT_ORDER + 1 ) )
#define HEADROT_SHMAT_DIM2 ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM )
#endif
/*----------------------------------------------------------------------------------*
* TD Binaural Object renderer
*----------------------------------------------------------------------------------*/
#ifdef EXT_RENDERER
#define MAX_NUM_TDREND_CHANNELS 16 /* max. number of channels in TD renderer (objects or loudspeaker channels) */
#else
#define MAX_NUM_TDREND_CHANNELS 11 /* max. number of channels in TD renderer (objects or loudspeaker channels) */
#endif
#define SFX_SPAT_BIN_MAX_NO_OF_OUTPUT_SAMPLES 288 /* 288 = 6 msec @ 48 kHz. */
#define HRTF_MODEL_N_SECTIONS 3 /* No. sections used in approximate evaluation of model */
......@@ -1424,36 +1445,33 @@ typedef enum
/*----------------------------------------------------------------------------------*
* Crend constants
* Orientation tracking constants
*----------------------------------------------------------------------------------*/
#define IVAS_REV_MAX_NR_BRANCHES 8 /* setup is for maximum */
#define IVAS_REV_MAX_IIR_FILTER_LENGTH 4 /* maximum nr of taps - MUST BE EVEN! */
#define RV_FILTER_MAX_FFT_SIZE ( 512 )
#define RV_FILTER_MAX_HISTORY ( 512 - 160 ) /* for longest history */
#define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1
/* Orientation tracking types */
#define IVAS_ORIENT_TRK_REF 0
#define IVAS_ORIENT_TRK_AVG 1
typedef enum
{
OTR_TRACKING_NONE = IVAS_ORIENT_TRK_REF-1, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */
OTR_TRACKING_NONE = IVAS_ORIENT_TRK_REF-1, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */ // VE: not really used in IVAS (only in unit-test)
OTR_TRACKING_REF_ORIENT = IVAS_ORIENT_TRK_REF, /* track orientation relative to external reference orientation (default: yaw=pitch=roll=0) */
OTR_TRACKING_AVG_ORIENT = IVAS_ORIENT_TRK_AVG /* track orientation relative to average orientation */
} OTR_TRACKING_T;
} OTR_TRACKING_T;
/*----------------------------------------------------------------------------------*
* Reverberator constants
*----------------------------------------------------------------------------------*/
#define IVAS_REV_MAX_NR_BRANCHES 8 /* setup is for maximum */
#define IVAS_REV_MAX_IIR_FILTER_LENGTH 4 /* maximum nr of taps - MUST BE EVEN! */
#define RV_FILTER_MAX_FFT_SIZE ( 512 )
#define RV_FILTER_MAX_HISTORY ( 512 - 160 ) /* for longest history */
#define RV_LENGTH_NR_FC ( RV_FILTER_MAX_FFT_SIZE / 2 ) + 1
#define IVAS_REVERB_DEFAULT_N_BANDS 31
#define IVAS_REVERB_DEFAULT_PRE_DELAY 0.016f
#define IVAS_REVERB_DEFAULT_INPUT_DELAY 0.1f
......@@ -1463,13 +1481,6 @@ typedef enum
* FB mixer constants
*----------------------------------------------------------------------------------*/
#define IVAS_ONE_BY_960 0.001041666666666666f
#define IVAS_ONE_BY_640 0.0015625f
#define IVAS_ONE_BY_320 0.003125f
#define IVAS_ONE_BY_240 0.004166666666666667f
#define IVAS_ONE_BY_160 0.00625f
#define IVAS_ONE_BY_80 0.0125f
#define IVAS_960_PT_LEN 960
#define IVAS_640_PT_LEN 640
#define IVAS_480_PT_LEN 480
......@@ -1479,8 +1490,6 @@ typedef enum
#define IVAS_80_PT_LEN 80
#define IVAS_40_PT_LEN 40
#define IVAS_NUM_SUPPORTED_FS 3
/* FB windows ovlp */
#define IVAS_FB_4MS_48K_SAMP 192
#define IVAS_FB_1MS_48K_SAMP 48
......
......@@ -169,22 +169,22 @@ void ivas_spar_covar_smooth_enc_close(
static void ivas_compute_smooth_cov(
ivas_cov_smooth_state_t *hCovState,
ivas_cov_smooth_in_buf_t *pIn_buf,
ivas_filterbank_t *pFb,
float *pCov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *pPrior_cov_buf[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
const float fac,
const int16_t start_band,
const int16_t end_band )
const int16_t end_band,
const int16_t num_ch,
const int16_t transient_det )
{
int16_t i, j, k;
int16_t prev_idx = hCovState->prior_bank_idx;
int16_t num_ch = pIn_buf->num_ch;
float factor = 0;
assert( end_band <= pFb->filterbank_num_bands );
if ( prev_idx == -1 || pIn_buf->reset_cov == 1 )
if ( prev_idx == -1 || transient_det == 1 )
{
for ( i = 0; i < num_ch; i++ )
{
......@@ -229,22 +229,23 @@ static void ivas_compute_smooth_cov(
void ivas_cov_smooth_process(
ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */
ivas_cov_smooth_in_buf_t *pIn_buf,
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
ivas_filterbank_t *pFb, /* i/o: FB handle */
const int16_t start_band,
const int16_t end_band )
const int16_t end_band,
const int16_t num_ch,
const int16_t transient_det )
{
int16_t i, j;
int16_t num_ch = pIn_buf->num_ch;
int16_t num_bands = end_band - start_band;
ivas_compute_smooth_cov( hCovState, pIn_buf, pFb, pIn_buf->cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band );
ivas_compute_smooth_cov( hCovState, pFb, cov_real, hCovState->pPrior_cov_real, 1e-20f, start_band, end_band, num_ch, transient_det );
for ( i = 0; i < num_ch; i++ )
{
for ( j = 0; j < num_ch; j++ )
{
mvr2r( &pIn_buf->cov_real[i][j][start_band], &hCovState->pPrior_cov_real[i][j][start_band], num_bands );
mvr2r( &cov_real[i][j][start_band], &hCovState->pPrior_cov_real[i][j][start_band], num_bands );
}
}
......
......@@ -60,7 +60,7 @@ ivas_error ivas_dirac_config(
)
{
IVAS_FORMAT ivas_format;
int16_t sba_order, sba_planar;
int16_t sba_order;
int16_t *nSCE, *nCPE, *element_mode, *nchan_transport;
int32_t ivas_total_brate;
DIRAC_CONFIG_DATA_HANDLE hConfig;
......@@ -83,7 +83,6 @@ ivas_error ivas_dirac_config(
element_mode = &( (Encoder_Struct *) st_ivas )->hEncoderConfig->element_mode_init;
nchan_transport = &( (Encoder_Struct *) st_ivas )->nchan_transport;
sba_order = ( (Encoder_Struct *) st_ivas )->sba_analysis_order;
sba_planar = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->sba_planar;
ivas_total_brate = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->ivas_total_brate;
Fs = ( (Encoder_Struct *) st_ivas )->hEncoderConfig->input_Fs;
band_grouping = ( (Encoder_Struct *) st_ivas )->hDirAC->band_grouping;
......@@ -108,7 +107,6 @@ ivas_error ivas_dirac_config(
element_mode = &( (Decoder_Struct *) st_ivas )->element_mode_init;
nchan_transport = &( (Decoder_Struct *) st_ivas )->nchan_transport;
sba_order = ( (Decoder_Struct *) st_ivas )->sba_analysis_order;
sba_planar = ( (Decoder_Struct *) st_ivas )->sba_planar;
ivas_total_brate = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->ivas_total_brate;
Fs = ( (Decoder_Struct *) st_ivas )->hDecoderConfig->output_Fs;
band_grouping = ( (Decoder_Struct *) st_ivas )->hDirAC->band_grouping;
......@@ -142,8 +140,7 @@ ivas_error ivas_dirac_config(
if ( ivas_format == SBA_FORMAT ) /* skip for MASA decoder */
{
if ( ( error = ivas_dirac_sba_config( hQMetaData, nchan_transport, nSCE, nCPE, element_mode, ivas_total_brate, sba_order, sba_planar,
sba_mode, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK )
if ( ( error = ivas_dirac_sba_config( hQMetaData, nchan_transport, nSCE, nCPE, element_mode, ivas_total_brate, sba_order, sba_mode, hConfig->nbands - spar_dirac_split_band ) ) != IVAS_ERR_OK )
{
return error;
}
......@@ -307,7 +304,6 @@ ivas_error ivas_dirac_sba_config(
int16_t *element_mode, /* i/o: element mode of the core coder */
int32_t sba_total_brate, /* i : SBA total bitrate */
const int16_t sba_order, /* i : Ambisonic (SBA) order */
const int16_t sba_planar, /* i : SBA planar flag */
const SBA_MODE sba_mode, /* i : SBA mode */
const int16_t nbands /* i : number of frequency bands */
)
......@@ -323,7 +319,7 @@ ivas_error ivas_dirac_sba_config(
if ( sba_mode == SBA_MODE_SPAR )
{
/* map the bitrate for SID frame */
if ( sba_total_brate == IVAS_SID_5k )
if ( sba_total_brate == IVAS_SID_5k2 )
{
if ( *element_mode == IVAS_SCE )
{
......@@ -420,11 +416,11 @@ ivas_error ivas_dirac_sba_config(
return error;
}
if ( sba_total_brate > IVAS_SID_4k4 )
if ( sba_total_brate > IVAS_SID_5k2 )
{
*nchan_transport = ivas_dirac_getNumTransportChannels( sba_total_brate, sba_order, sba_planar );
*nchan_transport = ivas_get_sba_num_TCs( sba_total_brate, sba_order );
}
else if ( sba_total_brate == IVAS_SID_4k4 )
else if ( sba_total_brate == IVAS_SID_5k2 )
{
switch ( *element_mode )
{
......@@ -564,79 +560,6 @@ ivas_error ivas_dirac_sba_config(
}
/*-------------------------------------------------------------------------
* ivas_dirac_getNumTransportChannels()
*
*
*------------------------------------------------------------------------*/
/*! r: number of IVAS transport channels */
int16_t ivas_dirac_getNumTransportChannels(
const int32_t sba_total_brate, /* i : SBA total bitrate */
const int16_t sba_order, /* i : SBA order */
const int16_t sba_planar /* i : SBA planar flag */
)
{
int16_t num_channels;
num_channels = 0;
if ( sba_total_brate >= DIRAC_MIN_BITRATE_8_TRANS_CHAN )
{
switch ( sba_order )
{
case 3:
num_channels = sba_planar ? 7 : 8;
break;
case 2:
num_channels = sba_planar ? 5 : 6;
break;
case 1:
num_channels = sba_planar ? 3 : 4;
break;
default:
assert( 0 && "Order not supported!" );
}
}
else if ( sba_total_brate >= DIRAC_MIN_BITRATE_6_TRANS_CHAN )
{
switch ( sba_order )
{
case 3:
case 2:
num_channels = sba_planar ? 5 : 6;
break;
case 1:
num_channels = sba_planar ? 3 : 4;
break;
default:
assert( 0 && "Order not supported!" );
}
}
else if ( sba_total_brate >= DIRAC_MIN_BITRATE_4_TRANS_CHAN )
{
if ( sba_planar )
{
num_channels = 3;
}
else
{
num_channels = 4;
}
}
else if ( sba_total_brate >= DIRAC_MIN_BITRATE_2_TRANS_CHAN )
{
num_channels = 2;
}
else
{
num_channels = 1;
}
return num_channels;
}
/*-------------------------------------------------------------------------
* computeDirectionVectors()
*
......
......@@ -59,7 +59,11 @@ typedef enum
IVAS_ERR_INVALID_CICP_INDEX,
IVAS_ERR_INVALID_BITRATE,
IVAS_ERR_INVALID_MASA_CONFIG,
#ifdef EXT_RENDERER
IVAS_ERR_TOO_MANY_INPUTS,
#else
IVAS_ERR_TOO_MANY_OBJECT_INPUTS,
#endif
IVAS_ERR_INDEX_OUT_OF_BOUNDS,
IVAS_ERR_RECONFIGURE_NOT_SUPPORTED,
IVAS_ERR_INVALID_FEC_CONFIG,
......@@ -80,12 +84,15 @@ typedef enum
IVAS_ERR_INVALID_INDEX,
IVAS_ERR_NOT_SUPPORTED_OPTION,
IVAS_ERR_NOT_IMPLEMENTED,
#ifdef DEBUGGING
IVAS_ERR_INVALID_FORCE_MODE,
#endif
IVAS_ERR_FILE_READER_TIMESTAMP_MISMATCH,
IVAS_ERR_ISM_FILE_READER_INVALID_METADATA_FORMAT,
IVAS_ERR_INVALID_MASA_FORMAT_METADATA_FILE,
#ifdef DEBUGGING
IVAS_ERR_INVALID_FORCE_MODE,
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
IVAS_ERR_INVALID_AGC,
#endif
#endif
/*----------------------------------------*
* input data errors *
......@@ -115,6 +122,18 @@ typedef enum
IVAS_ERR_BITSTREAM_READER_INVALID_DATA,
IVAS_ERR_BITSTREAM_READER_INVALID_FORMAT,
#ifdef EXT_RENDERER
/*----------------------------------------*
* renderer (lib_rend only) *
*----------------------------------------*/
IVAS_ERR_NUM_CHANNELS_UNKNOWN,
IVAS_ERR_INVALID_CUSTOM_LS_LAYOUT,
IVAS_ERR_INVALID_INPUT_ID,
IVAS_ERR_WRONG_NUM_CHANNELS,
IVAS_ERR_INVALID_BUFFER_SIZE,
#endif
/*----------------------------------------*
* unknown error *
*----------------------------------------*/
......@@ -147,6 +166,20 @@ static inline const char *ivas_error_to_string( ivas_error error_code )
return "Internal error";
case IVAS_ERR_INTERNAL_FATAL:
return "Internal fatal error";
#ifdef EXT_RENDERER
case IVAS_ERR_INVALID_SAMPLING_RATE:
return "Invalid sampling rate";
case IVAS_ERR_INVALID_OUTPUT_FORMAT:
return "Invalid output format";
case IVAS_ERR_INVALID_CUSTOM_LS_LAYOUT:
return "Invalid custom loudspeaker layout";
case IVAS_ERR_INVALID_INPUT_ID:
return "Invalid input ID";
case IVAS_ERR_WRONG_NUM_CHANNELS:
return "Wrong number of channels";
case IVAS_ERR_INVALID_BUFFER_SIZE:
return "Invalid buffer size";
#endif
case IVAS_ERR_FAILED_FILE_OPEN:
return "File open error";
case IVAS_ERR_FAILED_FILE_WRITE:
......
......@@ -42,7 +42,7 @@
/*------------------------------------------------------------------------------------------*
* Static functions declaration
* Local functions declaration
*------------------------------------------------------------------------------------------*/
static void ivas_iir_2_filter( ivas_filters_process_state_t *filter_state, float *pIn_Out, const int16_t length, const int16_t stage );
......@@ -55,9 +55,9 @@ static void ivas_iir_2_filter( ivas_filters_process_state_t *filter_state, float
*-----------------------------------------------------------------------------------------*/
void ivas_filters_init(
ivas_filters_process_state_t *filter_state,
const float *filt_coeff,
const int16_t order )
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
const float *filt_coeff, /* i : filter coefficients */
const int16_t order ) /* i : filter order */
{
int16_t i;
filter_state->order = order;
......@@ -107,9 +107,9 @@ void ivas_filters_init(
*-----------------------------------------------------------------------------------------*/
void ivas_filter_process(
ivas_filters_process_state_t *filter_state,
float *pIn_Out,
const int16_t length )
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
float *pIn_Out, /* i/o: signal subject to filtering */
const int16_t length ) /* i : filter order */
{
switch ( filter_state->order )
......
......@@ -42,6 +42,18 @@
#include "wmops.h"
/*-----------------------------------------------------------------------------------------*
* Local constants
*-----------------------------------------------------------------------------------------*/
#define IVAS_ONE_BY_960 0.001041666666666666f
#define IVAS_ONE_BY_640 0.0015625f
#define IVAS_ONE_BY_320 0.003125f
#define IVAS_ONE_BY_240 0.004166666666666667f
#define IVAS_ONE_BY_160 0.00625f
#define IVAS_ONE_BY_80 0.0125f
/*-----------------------------------------------------------------------------------------*
* Function ivas_get_mdft_twid_factors()
*
......
......@@ -136,11 +136,11 @@ static void house_refl(
}
else
{
float _rcp = 1.f / ( *normu );
float rcp = 1.f / ( *normu );
for ( i = 0; i < sizex; i++ )
{
pu[i] *= _rcp;
pu[i] *= rcp;
}
if ( pu[0] >= 0.f )
{
......@@ -152,11 +152,11 @@ static void house_refl(
pu[0] -= 1;
}
_rcp = 1.f / sqrtf( fabsf( pu[0] ) );
rcp = inv_sqrt( fabsf( pu[0] ) );
for ( i = 0; i < sizex; i++ )
{
pu[i] *= _rcp;
pu[i] *= rcp;
}
}
......@@ -645,7 +645,7 @@ static void norm_quat(
norm_q = dotp( q, q, IVAS_PCA_INTERP );
norm_q = 1 / sqrtf( norm_q ); // VE: TBV: possible division by 0
norm_q = inv_sqrt( norm_q ); // VE: TBV: possible division by 0
for ( i = 0; i < IVAS_PCA_INTERP; i++ )
{
......
......@@ -45,7 +45,6 @@
#include "ivas_stat_com.h"
#include "ivas_error_utils.h"
/* clang-format off */
/*----------------------------------------------------------------------------------*
......@@ -106,7 +105,17 @@ ivas_error mct_enc_reconfigure(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const uint16_t b_nchan_change /* i : flag indicating different channel count */
);
#ifdef SBA_BR_SWITCHING
ivas_error ivas_sba_enc_reinit(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
#endif
#ifdef SBA_BR_SWITCHING
int16_t get_sba_reinit_flag(
int32_t ivas_total_bitrate, /* i: current bitrate */
int32_t last_ivas_total_brate /* i: previous bitrate */
);
#endif
ivas_error ivas_sba_enc_reconfigure(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
......@@ -119,6 +128,17 @@ void destroy_cpe_enc(
CPE_ENC_HANDLE hCPE /* i/o: CPE encoder structure */
);
void ivas_mct_enc_close(
MCT_ENC_HANDLE hMCT /* i/o: MCT encoder structure */
);
ivas_error ivas_corecoder_enc_reconfig(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t nSCE_old, /* i : number of SCEs in previous frame */
const int16_t nCPE_old, /* i : number of CPEs in previous frame */
const int16_t nchan_transport_old /* i : number of TCs in previous frame */
);
ivas_error ivas_sce_enc(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t sce_id, /* i : SCE # identifier */
......@@ -191,6 +211,7 @@ ivas_error pre_proc_ivas(
Encoder_State *st, /* i/o: encoder state structure */
const int16_t last_element_mode, /* i : last element mode */
const int32_t element_brate, /* i : element bitrate */
const int32_t last_element_brate, /* i : last element bitrate */
const int16_t input_frame, /* i : frame length */
float old_inp_12k8[], /* i/o: buffer of old input signal */
float old_inp_16k[], /* i/o: buffer of old input signal @ 16kHz */
......@@ -209,7 +230,7 @@ ivas_error pre_proc_ivas(
const int16_t vad_flag_dtx, /* i : HE-SAD flag with additional DTX HO */
const float enerBuffer[CLDFB_NO_CHANNELS_MAX], /* i : energy buffer */
const float fft_buff[2 * L_FFT], /* i : FFT buffer */
const int16_t is_mct, /* i : MCT mode flag */
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int16_t vad_hover_flag, /* i : VAD hangover flag */
const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
);
......@@ -238,11 +259,9 @@ uint32_t ivas_syn_output(
int16_t *synth_out /* o : integer 16 bits synthesis signal */
);
#ifdef FIX_I98_HANDLES_TO_NULL
void ivas_initialize_handles_enc(
Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */
);
#endif
ivas_error ivas_init_encoder(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
......@@ -317,6 +336,19 @@ void ivas_mct_dec_close(
MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */
);
ivas_error ivas_corecoder_dec_reconfig(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t nSCE_old, /* i : number of SCEs in previous frame */
const int16_t nCPE_old, /* i : number of CPEs in previous frame */
const int16_t nchan_transport_old, /* i : number of TCs in previous frame */
const int16_t sba_dirac_stereo_flag_old /* i : signal stereo output for SBA DirAC in previous frame */
);
ivas_error ivas_hp20_dec_reconfig(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t nchan_hp20_old /* i : number of HP20 filters in previous frame*/
);
ivas_error ivas_sce_dec(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
const int16_t sce_id, /* i : SCE # identifier */
......@@ -387,6 +419,7 @@ ivas_error ivas_core_enc(
float enerBuffer[CPE_CHANNELS][CLDFB_NO_CHANNELS_MAX], /* i : energy buffer */
float fft_buff[CPE_CHANNELS][2 * L_FFT], /* i : FFT buffer */
const int16_t tdm_SM_flag, /* i : channel combination scheme flag */
const int16_t ivas_format, /* i : IVAS format */
const int16_t flag_16k_smc /* i : flag to indicate if the OL SMC is run at 16 kHz */
);
......@@ -472,7 +505,7 @@ void stereo_tcx_core_dec(
void stereo_tcx_init_dec(
Decoder_State *st, /* i/o: decoder state structure */
const int16_t is_mct, /* i : MCT mode flag */
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int16_t last_element_mode /* i : element mode of previous frame */
);
......@@ -529,7 +562,7 @@ void ivas_decision_matrix_enc(
void ivas_signaling_enc(
Encoder_State *st, /* i/o: encoder state structure */
const int16_t is_MCT, /* i : MCT enabled */
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int32_t element_brate, /* i : element bitrate */
const int16_t tdm_SM_flag, /* i : channel combination scheme flag in TD stereo */
const int16_t tdm_Pitch_reuse_flag /* i : primary channel pitch reuse flag in TD stereo*/
......@@ -892,10 +925,6 @@ void stereo_enc_itd_init(
void stereo_dft_enc_update(
STEREO_DFT_ENC_DATA_HANDLE hStereoDft, /* i/o: encoder DFT stereo handle */
const int16_t max_bwidth /* i : maximum encoded bandwidth */
#ifdef DEBUG_MODE_DFT
,
const int16_t res_code_bits /* i : bits for residual coding */
#endif
);
void stereo_dft_enc_destroy(
......@@ -1871,7 +1900,7 @@ void EstimateStereoTCXNoiseLevel(
const int16_t ignore_chan[], /* i : flag indicating whether the channel should be ignored */
float fac_ns[][NB_DIV], /* o : noise filling level */
int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */
const int16_t is_mct /* i : is mct flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void TNSAnalysisStereo(
......@@ -1982,17 +2011,12 @@ void decoder_tcx_invQ(
const int16_t **prm_sqQ,
int16_t *nf_seed,
const int16_t bfi, /* i : Bad frame indicator */
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
const int16_t isMCT,
#endif
const int16_t frame_cnt /* i : frame counter in the super frame */
);
void decoder_tcx_noisefilling(
Decoder_State *st, /* i/o: coder memory state */
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
float concealment_noise[L_FRAME48k],
#endif
const float A[], /* i : coefficients NxAz[M+1] */
const int16_t L_frameTCX_glob,
const int16_t L_spec,
......@@ -2005,9 +2029,7 @@ void decoder_tcx_noisefilling(
const int16_t *prm_sqQ,
int16_t nf_seed,
const int16_t bfi, /* i : Bad frame indicator */
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
const int16_t isMCT,
#endif
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int16_t frame_cnt /* i : frame counter in the super frame */
);
......@@ -2090,7 +2112,8 @@ void decoder_tcx_IGF_stereo(
const int16_t L_frame, /* i : frame length */
const int16_t left_rect, /* i : left part is rectangular */
const int16_t k, /* i : Subframe index */
const int16_t bfi /* i : bad frame indicator */
const int16_t bfi, /* i : bad frame indicator */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void ms_processing(
......@@ -2123,7 +2146,8 @@ void IGFDecApplyStereo(
const int16_t igfGridIdx, /* i : in case of CELP->TCX switching, use 1.25 framelength */
const int16_t *coreMsMask,
const int16_t restrict_hopsize,
const int16_t bfi /* i : frame loss == 1, frame good == 0 */
const int16_t bfi, /* i : frame loss == 1, frame good == 0 */
const int16_t bfi_apply_damping /* i : decoder element mode */
);
void IGFEncStereoEncoder(
......@@ -2174,7 +2198,8 @@ void stereo_decoder_tcx(
const int16_t core_l, /* i : core for left channel (TCX20/TCX10) */
const int16_t core_r, /* i : core for right channel (TCX20/TCX10) */
const int16_t igf, /* i : flag for IGF activity */
const int16_t L_frame, /* i : TCX frame length */
const int16_t L_frameTCX_l, /* i : TCX frame length of left channel */
const int16_t L_frameTCX_r, /* i : TCX frame length of right channel */
const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */
const int16_t last_core_l, /* i : last core for left channel */
const int16_t last_core_r, /* i : last core for right channel */
......@@ -2362,7 +2387,7 @@ ivas_error front_vad(
Encoder_State *st, /* i/o: encoder state structure */
const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
FRONT_VAD_ENC_HANDLE *hFrontVads, /* i/o: front-VAD handles */
const int16_t hMCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int16_t input_frame, /* i : frame length */
int16_t vad_flag_dtx[], /* o : HE-SAD flag with additional DTX HO */
float fr_bands[][2 * NB_BANDS], /* i : energy in frequency bands */
......@@ -2640,7 +2665,7 @@ void ivas_mdct_quant_coder(
int16_t tnsBits[CPE_CHANNELS][NB_DIV], /* i : bits needed for TNS parameters */
int16_t tnsSize[CPE_CHANNELS][NB_DIV], /* i : size of TNS */
int16_t p_param[CPE_CHANNELS][NB_DIV], /* i : pointer to parameter array */
const int16_t is_mct /* i : is mct flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void apply_MCT_enc(
......@@ -2690,7 +2715,7 @@ void ivas_mdct_dec_side_bits_frame_channel(
int16_t *LFE_off, /* o : flag if LFE has content */
int16_t nTnsBitsTCX10[CPE_CHANNELS][NB_DIV], /* o : number of bits for TNS */
int16_t param[CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV], /* i/o: parameters buffer */
const int16_t MCT_flag, /* i : MCT tool active(1) or deactive (0) */
const int16_t MCT_flag, /* i : hMCT handle allocated (1) or not (0) */
const int16_t odd_channel_cpe /* i : flag cpe with odd nb of tc channels */
);
......@@ -2718,7 +2743,7 @@ void ivas_mdct_core_invQ(
float *x[CPE_CHANNELS][NB_DIV], /* i/o: signal buffer */
float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* i : LP coefficients */
int16_t ms_mask[NB_DIV][MAX_SFB], /* i : M/S mask */
const int16_t isMCT /* i : MCT flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void ivas_mdct_core_reconstruct(
......@@ -2727,7 +2752,7 @@ void ivas_mdct_core_reconstruct(
float signal_outFB[CPE_CHANNELS][L_FRAME_PLUS], /* o : synthesis @output_FS */
const int16_t LFE_off, /* i : flag if LFE content */
int16_t fUseTns[CPE_CHANNELS][NB_DIV], /* i : flage TNS enabled */
const int16_t isMCT /* i : MCT flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void ivas_mdct_core_tns_ns(
......@@ -2737,7 +2762,7 @@ void ivas_mdct_core_tns_ns(
STnsData tnsData[CPE_CHANNELS][NB_DIV], /* o : TNS parameter */
float *x[CPE_CHANNELS][NB_DIV], /* o : synthesis @internal_FS */
float Aq[CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )], /* o : LP coefficients */
const int16_t isMCT /* i : MCT flag */
const int16_t MCT_flag /* i : hMCT handle allocated (1) or not (0) */
);
void ivas_mct_core_dec(
......@@ -2766,10 +2791,6 @@ void mctStereoIGF_dec(
const int16_t bfi /* i : bad frame flag */
);
void ivas_mct_enc_close(
MCT_ENC_HANDLE hMCT /* i/o: MCT encoder structure */
);
void ivas_mdct_tcx10_bit_distribution(
int16_t target_bitsTCX10[NB_DIV], /* o : target bit distribution */
const int16_t bits_frame_channel, /* i : bits frame channel */
......@@ -2803,8 +2824,7 @@ void reset_metadata_spatial(
int32_t *total_brate, /* o : total bitrate */
const int32_t core_brate, /* i : core bitrate */
const int16_t nb_bits_metadata, /* i : number of meatdata bits */
const SBA_MODE sba_mode, /* i : SBA mode */
const int16_t element_mode /* i : element mode */
const SBA_MODE sba_mode /* i : SBA mode */
);
/*! r: number of bits written */
......@@ -3035,6 +3055,8 @@ void ivas_dirac_param_est_enc(
float **pp_fr_real,
float **pp_fr_imag,
const int16_t input_frame
,
const SBA_MODE sba_mode
);
/*----------------------------------------------------------------------------------*
......@@ -3054,10 +3076,13 @@ void ivas_sba_config(
const int16_t sba_planar, /* i : SBA planar flag */
int16_t *nSCE, /* o : number of SCEs */
int16_t *nCPE, /* o : number of CPEs */
int16_t *element_mode, /* o : element mode of the core coder */
const SBA_MODE sba_mode /* i : SBA mode */
int16_t *element_mode /* o : element mode of the core coder */
);
#ifdef SBA_BR_SWITCHING
ivas_error ivas_sba_dec_reinit(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
#endif
ivas_error ivas_sba_dec_reconfigure(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
......@@ -3095,6 +3120,12 @@ int16_t ivas_sba_get_nchan_metadata(
const int16_t sba_order /* i : Ambisonic (SBA) order */
);
/*! r: flag indicating to code SPAR HOA MD for all bands */
int16_t ivas_sba_get_spar_hoa_md_flag(
const int16_t sba_order, /* i : Ambisonic (SBA) order */
const int32_t ivas_total_brate /* i : IVAS total bitrate */
);
void ivas_sba_zero_vert_comp(
float sba_data[][L_FRAME48k], /* i/o: SBA data frame */
const int16_t sba_order, /* i : Ambisonic (SBA) order */
......@@ -3143,6 +3174,16 @@ ivas_error ivas_sba_get_hoa_dec_matrix(
const int16_t ambisonics_order /* i : Ambisonics order */
);
#ifdef EXT_RENDERER
void ivas_sba_mtx_mult(
float output_f[][L_FRAME48k], /* i/o: synthesized core-corder transport channels/DirAC output */
const int16_t output_frame, /* i : frame length per channel */
const int16_t nchan_in, /* i : Number of ambisonic channels */
const IVAS_OUTPUT_SETUP output_setup, /* i : Output configuration */
const float *mtx_hoa_decoder /* o : HOA decoding matrix */
);
#endif
/*----------------------------------------------------------------------------------*
* DirAC prototypes
*----------------------------------------------------------------------------------*/
......@@ -3166,7 +3207,7 @@ void ivas_dirac_enc(
BSTR_ENC_HANDLE hMetaData, /* i/o: Metadata bitstream handle */
int16_t *nb_bits_metadata, /* o : number of metadata bits written */
const int16_t Opt_DTX_ON, /* i : flag signaling DTX on */
float data_f[][L_FRAME48k], /* i/o: input: ACN/SN3D, output: omni, stereo DMX or FOA */
float data_f[][L_FRAME48k], /* i/o: SBA channels */
const int16_t input_frame, /* i : input frame length */
const int16_t sba_planar /* i : SBA planar flag */
);
......@@ -3194,18 +3235,10 @@ ivas_error ivas_dirac_sba_config(
int16_t *element_mode, /* o : element mode of the core coder */
int32_t sba_total_brate, /* i : SBA total bitrate */
const int16_t sba_order, /* i : Ambisonic (SBA) order */
const int16_t sba_planar, /* i : SBA planar flag */
const SBA_MODE sba_mode, /* i : SBA mode */
const int16_t nbands /* i : number of frequency bands */
);
/*! r: number of IVAS transport channels */
int16_t ivas_dirac_getNumTransportChannels(
const int32_t sba_total_brate, /* i : SBA total bitrate */
const int16_t sba_order, /* i : SBA order */
const int16_t sba_planar /* i : SBA Planar flag */
);
ivas_error ivas_dirac_dec_open(
Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
);
......@@ -3255,7 +3288,11 @@ void ivas_dirac_dec_binaural(
ivas_error ivas_binaural_reverb_open(
REVERB_STRUCT_HANDLE *hReverbPr, /* i/o: binaural reverb handle */
const int16_t numBins, /* i : number of CLDFB bins */
const int16_t numCldfbSlotsPerFrame /* i : number of CLDFB slots per frame, i.e., reverberator block size */
const int16_t numCldfbSlotsPerFrame, /* i : number of CLDFB slots per frame */
ivas_roomAcoustics_t *roomAcoustics, /* i/o: room acoustics parameters */
const AUDIO_CONFIG output_config, /* i : output audio configuration */
const int32_t sampling_rate, /* i : sampling rate */
const RENDERER_TYPE renderer_type /* i : renderer type */
);
void ivas_binaural_reverb_close(
......@@ -3750,9 +3787,6 @@ void ivas_spar_config(
void ivas_sba_upmixer_renderer(
Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */
float output[][L_FRAME48k], /* i/o: transport/output audio channels */
#ifndef SPAR_SCALING_HARMONIZATION
const int16_t nchan_remapped, /* i : num channels after remapping of TCs */
#endif
const int16_t output_frame /* i : output frame length */
);
......@@ -3773,6 +3807,14 @@ void ivas_sba_prototype_renderer(
);
/* AGC */
/*! r: AGC enable flag */
int16_t ivas_agc_enc_get_flag(
#ifdef DEBUG_AGC_ENCODER_CMD_OPTION
int16_t agc_configuration, /* i : AGC configuration from command-line */
#endif
int16_t nchan_transport /* i : number of transport channels */
);
ivas_error ivas_spar_agc_enc_open(
ivas_agc_enc_state_t **hAgcEnc, /* i/o: AGC decoder handle */
const int32_t input_Fs, /* i : input sampling rate */
......@@ -3851,7 +3893,8 @@ int16_t ivas_get_spar_table_idx(
int16_t *ind /* o : indice */
);
int16_t ivas_get_spar_num_TCs(
/*! r: number of transport channels */
int16_t ivas_get_sba_num_TCs(
const int32_t ivas_total_brate, /* i : IVAS total bitrate */
const int16_t sba_order /* i : IVAS SBA order */
);
......@@ -3912,9 +3955,11 @@ void ivas_spar_md_enc_close(
ivas_error ivas_spar_md_enc_process(
ivas_spar_md_enc_state_t *hMdEnc, /* i/o: SPAR MD encoder handle */
const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */
ivas_spar_md_enc_in_buf_t *pIn_buf,
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */
const int16_t dtx_silence_mode,
const int16_t dtx_vad,
const int16_t nchan_inp,
const int16_t sba_order /* i : Ambisonic (SBA) order */
);
......@@ -3977,7 +4022,8 @@ void ivas_get_spar_md_from_dirac(
ivas_error ivas_spar_md_dec_open(
ivas_spar_md_dec_state_t **hMdDec_out, /* i/o: SPAR MD decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
const int16_t num_channels /* i : number of internal channels */
const int16_t num_channels, /* i : number of internal channels */
const int16_t sba_order /* i : SBA order */
);
void ivas_spar_md_dec_close(
......@@ -3997,7 +4043,8 @@ void ivas_spar_get_parameters(
ivas_error ivas_spar_md_dec_init(
ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */
const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
const int16_t num_channels /* i : number of internal channels */
const int16_t num_channels, /* i : number of internal channels */
const int16_t sba_order /* i : SBA order */
);
void ivas_spar_md_dec_process(
......@@ -4050,12 +4097,17 @@ void ivas_spar_covar_enc_close(
void ivas_enc_cov_handler_process(
ivas_enc_cov_handler_state_t *hCovEnc, /* i/o: SPAR Covar. encoder handle */
ivas_enc_cov_handler_in_buf_t *pIn_buf,
float **ppIn_FR_real,
float **ppIn_FR_imag,
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *cov_dtx_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
ivas_filterbank_t *pFb, /* i/o: FB handle */
const int16_t start_band,
const int16_t end_band );
const int16_t end_band,
const int16_t nchan_inp,
const int16_t dtx_vad,
const int16_t transient_det
);
ivas_error ivas_spar_covar_smooth_enc_open(
ivas_cov_smooth_state_t **hCovState, /* i/o: SPAR Covar. smoothing handle */
......@@ -4071,10 +4123,12 @@ void ivas_spar_covar_smooth_enc_close(
void ivas_cov_smooth_process(
ivas_cov_smooth_state_t *hCovState, /* i/o: Covariance state handle */
ivas_cov_smooth_in_buf_t *pIn_buf,
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
ivas_filterbank_t *pFb, /* i/o: FB handle */
const int16_t start_band,
const int16_t end_band
const int16_t end_band,
const int16_t num_ch,
const int16_t transient_det
);
/* Transient detector module */
......@@ -4273,16 +4327,16 @@ int16_t ivas_map_num_decd_r_to_idx( const int16_t num_quant_points_decd_r );
/* Quantization utilities */
void ivas_quantise_real_values(
float **values,
const float *values,
const int16_t q_levels,
const float min_value,
const float max_value,
int16_t **index,
float **quant,
const int16_t dim1,
const int16_t dim2
int16_t *index,
float *quant,
const int16_t dim
);
void ivas_spar_get_uniform_quant_strat(
ivas_spar_md_com_cfg *pSpar_md_com_cfg,
const int16_t table_idx
......@@ -4509,17 +4563,33 @@ void ivas_binaural_add_LFE(
);
void QuatToRotMat(
#ifdef EXT_RENDERER
const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */
#else
const Quaternion quat, /* i : quaternion describing the rotation */
#endif
float Rmat[3][3] /* o : real-space rotation matrix for this rotation */
);
void Quat2Euler(
#ifdef EXT_RENDERER
const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */
#else
const Quaternion quat, /* i : quaternion describing the rotation */
#endif
float *yaw, /* o : yaw */
float *pitch, /* o : pitch */
float *roll /* o : roll */
);
#ifdef EXT_RENDERER
void SHrotmatgen(
float SHrotmat[SBA_NHARM_HOA3][SBA_NHARM_HOA3], /* o : SHD rotation matrix */
float Rmat[3][3], /* i : real-space rotation matrix */
const int16_t order /* i : ambisonics order */
);
#endif
void rotateAziEle(
float azi_in, /* i : output elevation */
float ele_in, /* i : input elevation */
......@@ -4544,7 +4614,9 @@ ivas_error ivas_headTrack_open(
void rotateFrame_shd(
HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
float output[][L_FRAME48k], /* i/o: unrotated HOA3 signal buffer in TD */
const int32_t output_fs, /* i : output sampling frequency */
#ifndef EXT_RENDERER
const int32_t output_Fs, /* i : output sampling frequency */
#endif
const int16_t subframe_len, /* i : subframe length per channel */
const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */
const int16_t subframe_idx /* i : subframe index */
......@@ -4553,7 +4625,9 @@ void rotateFrame_shd(
void rotateFrame_sd(
HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i : head track handle */
float output[][L_FRAME48k], /* i/o: unrotated SD signal buffer in TD */
const int32_t output_fs, /* i : output sampling frequency */
#ifndef EXT_RENDERER
const int32_t output_Fs, /* i : output sampling frequency */
#endif
const int16_t subframe_len, /* i : subframe length per channel */
const IVAS_OUTPUT_SETUP hTransSetup, /* i : format for rotation */
const EFAP_HANDLE hEFAPdata, /* i : EFAP structure */
......@@ -4724,7 +4798,11 @@ ivas_error ivas_ls_custom_output_init(
void ivas_ls_custom_setup(
IVAS_OUTPUT_SETUP_HANDLE hOutSetup, /* o : IVAS output setup handle */
#ifdef EXT_RENDERER
const LSSETUP_CUSTOM_STRUCT *hLsSetupCustom /* i : Custom loudspeaker setup handle */
#else
const LSSETUP_CUSTOM_HANDLE hLsSetupCustom /* i : Custom loudspeaker setup handle */
#endif
);
......@@ -4793,7 +4871,7 @@ void lls_interp_n(
const int16_t N, /* i : length of the input vector */
float *a, /* o : calculated slope */
float *b, /* o : calculated offset */
int16_t upd /* i : use 1 to update x[] with the interpolated output */
const int16_t upd /* i : use 1 to update x[] with the interpolated output*/
);
void computeReferencePower_enc(
......@@ -4803,6 +4881,8 @@ void computeReferencePower_enc(
float *reference_power, /* o : Estimated power */
const int16_t enc_param_start_band, /* i : first band to process */
const int16_t num_freq_bands /* i : Number of frequency bands */
,
const SBA_MODE sba_mode /* i : SBA mode */
);
......@@ -4888,15 +4968,15 @@ void ivas_lfe_lpf_select_filt_coeff(
);
void ivas_filters_init(
ivas_filters_process_state_t *filter_state,
const float *filt_coeff,
const int16_t order
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
const float *filt_coeff, /* i : filter coefficients */
const int16_t order /* i : filter order */
);
void ivas_filter_process(
ivas_filters_process_state_t *filter_state,
float *pIn_Out,
const int16_t length
ivas_filters_process_state_t *filter_state, /* i/o: filter state handle */
float *pIn_Out, /* i : signal subject to filtering */
const int16_t length /* i : filter order */
);
......@@ -4966,12 +5046,12 @@ void TDREND_HRFILT_SetFiltSet(
#endif
ivas_error TDREND_REND_RenderSourceHRFilt(
const TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */
TDREND_SRC_t *Src_p, /* i/o: The source to be rendered */
#ifdef TDREND_HRTF_TABLE_METHODS
BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */
#endif
float output_buf[][L_FRAME48k], /* o : Output buffer */
const int16_t output_frame, /* i : Output frame length in use */
float output_buf[][L_SPATIAL_SUBFR_48k], /* o : Output buffer */
const int16_t subframe_length, /* i : Subframe length in use */
const int32_t output_Fs /* i : Output sample rate */
);
......@@ -5111,7 +5191,7 @@ void TDREND_SFX_SpatBin_SetParams(
void TDREND_SFX_SpatBin_Execute_Main(
SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters handle */
const float *InBuffer_p, /* i : Input buffer */
const int16_t output_frame, /* i : frame length */
const int16_t subframe_length, /* i : subframe length */
float *LeftOutBuffer_p, /* o : Rendered left channel */
float *RightOutBuffer_p, /* o : Rendered right channel */
int16_t *NoOfUsedInputSamples_p, /* o : Number of input samples actually used */
......@@ -5155,7 +5235,7 @@ void ivas_fb_mixer_pcm_ingest(
void ivas_dirac_enc_spar_delay_synchro(
Encoder_Struct *st_ivas, /* i/o: IVAS encoder structure */
const int16_t input_frame, /* i : input frame length */
float data_f[][L_FRAME48k] /* i/o: input: ACN/SN3D, output: omni, stereo DMX or FOA*/
float data_f[][L_FRAME48k] /* i/o: SBA channels (ACN / SN3D) */
);
void ivas_fb_mixer_update_prior_input(
......@@ -5460,7 +5540,6 @@ ivas_error ivas_orient_trk_GetTrackedOrientation(
float *roll
);
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
void TonalMdctConceal_create_concealment_noise(
float concealment_noise[L_FRAME48k],
CPE_DEC_HANDLE hCPE,
......@@ -5469,14 +5548,29 @@ void TonalMdctConceal_create_concealment_noise(
const int16_t idchan,
const int16_t subframe_idx,
const int16_t core,
const int16_t crossfade_gain,
const float crossfade_gain,
const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode
);
#endif
void TonalMdctConceal_whiten_noise_shape(
Decoder_State *st,
const int16_t L_frame,
const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE
);
int16_t get_igf_startline(
Decoder_State *st,
int16_t L_frame,
int16_t L_frameTCX
);
float rand_triangular_signed(
int16_t *seed );
/* clang-format on */
void dtx_read_padding_bits(
DEC_CORE_HANDLE st,
int16_t num_bits );
#endif /* IVAS_PROT_H */
......@@ -49,7 +49,7 @@
const int32_t ivas_brate_tbl[SIZE_IVAS_BRATE_TBL] =
{
FRAME_NO_DATA, IVAS_SID_4k4, IVAS_SID_5k,
FRAME_NO_DATA, IVAS_SID_5k2,
IVAS_13k2, IVAS_16k4, IVAS_24k4, IVAS_32k, IVAS_48k,
IVAS_64k, IVAS_80k, IVAS_96k, IVAS_128k, IVAS_160k,
IVAS_192k, IVAS_256k, IVAS_384k, IVAS_512k
......@@ -903,57 +903,57 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] =
{
/* When AGC is ON additional (AGC_BITS_PER_CH+1) bits may be taken from each core-coder channel
so minimum core-coder bitrate per channel can be min core-coder bitrates as per the table - AGC_BITS_PER_CH */
{ 24400, 0, 1, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } },
{ 24400, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 16400, 14850, 24350 } },
{ { 15, 1, 5, 1 },{ 15, 1, 3, 1 },{ 7, 1, 3, 1 } }, 0, 0, 0 },
{ 32000, 0, 1, FB, 24000, 1, WYXZ, 1, 0,{ { 24000, 20450, 31950 } },
{ 32000, 0, SBA_FOA_ORDER, FB, 24000, 1, WYXZ, 1, 0,{ { 24000, 20450, 31950 } },
{ { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 },
{ 48000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 24000, 21000, 31950 },{ 16000, 15000, 20400 } },
{ 48000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 24000, 21000, 31950 },{ 16000, 15000, 20400 } },
{ { 15, 7, 5, 1 },{ 15, 7, 3, 1 },{ 7, 7, 3, 1 } }, 1, 0, 0 },
{ 64000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 },
{ 64000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 38000, 34050, 56000 },{ 16000, 15600, 20400 } },{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 1, 0 },
{ 80000, 0, 1, FB, 24000, 2, WYXZ, 0, 0,{ { 46000, 43000, 56000 },{ 24000, 23000, 31950 } },
{ 80000, 0, SBA_FOA_ORDER, FB, 24000, 2, WYXZ, 0, 0,{ { 46000, 43000, 56000 },{ 24000, 23000, 31950 } },
{ { 21, 7, 5, 1 },{ 15, 7, 5, 1 },{ 15, 7, 3, 1 } }, 1, 0, 0 },
{ 96000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } },
{ 96000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 47000, 42600, 56000 },{ 23000, 22600, 31950 },{ 16000, 15600, 20400 } },
{ { 21, 9, 9, 1 },{ 21, 7, 5, 1 },{ 21, 7, 5, 1 } }, 1, 0, 0 },
{ 128000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } },
{ 128000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 55000, 50000, 56000 },{ 36000, 36000, 56000 },{ 27000, 27000, 31950 } },
{ { 21, 11, 9, 1 },{ 21, 9, 7, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 },
{ 160000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } },
{ 160000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 74000, 70900, 112000 },{ 41000, 40050, 56000 },{ 35000, 34050, 56000 } },
{ { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 },
{ 192000, 0, 1, FB, 24000, 3, WYXZ, 0, 0,{ { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } },
{ 192000, 0, SBA_FOA_ORDER, FB, 24000, 3, WYXZ, 0, 0,{ { 90000, 87900, 112000 },{ 50000, 48050, 56000 },{ 42000, 41050, 56000 } },
{ { 21, 11, 11, 1 },{ 21, 9, 9, 1 },{ 21, 7, 7, 1 } }, 1, 0, 0 },
{ 256000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } },
{ 256000, 0, SBA_FOA_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 90000, 85000, 112000 },{ 70000, 69000, 112000 },{ 50000, 48950, 56000 },{ 36400, 35600, 56000 } },
{ { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
{ 256000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } },
{ 256000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 84650, 83000, 112000 },{ 65850, 64550, 56000 },{ 47000, 46100, 48000 },{ 28200, 27650, 40000 } },
{ { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
{ 256000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } },
{ 256000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 76300, 73550, 112000 },{ 59350, 57200, 56000 },{ 42400, 40850, 48000 },{ 25450, 24500, 40000 } },
{ { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 31, 1, 1, 1 } }, 1, 2, 0 },
{ 384000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 100000, 100000, 128000 },{ 79850, 79850, 104000 },{ 66600, 66600, 104000 } }, // not yet optimized
{ { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
{ 384000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational
{ 384000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 105350, 103300, 112000 },{ 75200, 73750, 96000 },{ 45100, 44250, 48000 } }, // just added as a place holder, not necessarily operational
{ { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
{ 384000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, // just added as a place holder, not necessarily operational
{ 384000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 124300, 121550, 128000 },{ 96700, 94550, 112000 },{ 69050, 67500, 96000 },{ 41450, 40500, 48000 } }, // just added as a place holder, not necessarily operational
{ { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
{ 512000, 0, 1, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 }, {118450, 118450, 128000 } }, // not yet optimized
{ { 31, 1, 1, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
{ 512000, 0, 2, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 97700, 93300, 128000 } }, // not yet optimized
{ 512000, 0, SBA_HOA2_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 97700, 93300, 128000 } }, // not yet optimized
{ { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
{ 512000, 0, 3, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 127200, 122550, 128000 },{ 76300, 73550, 128000 } }, // not yet optimized
{ 512000, 0, SBA_HOA3_ORDER, FB, 24000, 4, WYXZ, 0, 0,{ { 128000, 128000, 128000 },{ 128000, 128000, 128000 },{ 127200, 122550, 128000 },{ 76300, 73550, 128000 } }, // not yet optimized
{ { 31, 11, 11, 1 },{ 1, 1, 1, 1 },{ 1, 1, 1, 1 } }, 1, 2, 0 },
};
......
......@@ -72,6 +72,29 @@ SBA_MODE ivas_sba_mode_select(
return sba_mode;
}
#ifdef SBA_BR_SWITCHING
/*-------------------------------------------------------------------*
* get_sba_reinit_flag()
*
* Get SBA reinitialisation flag
*-------------------------------------------------------------------*/
int16_t get_sba_reinit_flag(
int32_t ivas_total_bitrate, /* i : Current bitrate */
int32_t last_ivas_total_brate /* i : Previous bitrate */
)
{
int16_t sba_reinit_flag;
sba_reinit_flag = 0;
if ( ivas_total_bitrate != last_ivas_total_brate && ( last_ivas_total_brate > IVAS_SID_5k2 ) && ( ivas_total_bitrate > IVAS_SID_5k2 ) )
{
sba_reinit_flag = 1;
}
return sba_reinit_flag;
}
#endif
/*-------------------------------------------------------------------*
* ivas_sba_config()
......@@ -87,8 +110,7 @@ void ivas_sba_config(
const int16_t sba_planar, /* i : SBA Planar flag */
int16_t *nSCE, /* o : number of SCEs */
int16_t *nCPE, /* o : number of CPEs */
int16_t *element_mode, /* o : element mode of the core coder */
const SBA_MODE sba_mode /* i : SBA mode */
int16_t *element_mode /* o : element mode of the core coder */
)
{
if ( ( sba_order < 0 ) && ( nb_channels < 0 ) )
......@@ -117,14 +139,7 @@ void ivas_sba_config(
if ( nchan_transport != NULL )
{
if ( sba_mode == SBA_MODE_SPAR )
{
*nchan_transport = ivas_get_spar_num_TCs( sba_total_brate, sba_order );
}
else
{
*nchan_transport = ivas_dirac_getNumTransportChannels( sba_total_brate, sba_order, sba_planar );
}
*nchan_transport = ivas_get_sba_num_TCs( sba_total_brate, sba_order );
}
/* Configure core coder number of elements*/
......@@ -202,7 +217,7 @@ int16_t ivas_sba_get_analysis_order(
if ( ivas_total_brate < SBA_MIN_BRATE_HOA )
{
/* Hard coding the sba_analysis_order as 1 as higher not supported below SBA_MIN_BRATE_HOA bitrate */
sba_analysis_order = 1;
sba_analysis_order = SBA_FOA_ORDER;
}
return sba_analysis_order;
......@@ -221,15 +236,15 @@ int16_t ivas_sba_get_order_transport(
{
int16_t sba_order;
sba_order = 1;
sba_order = SBA_FOA_ORDER;
if ( nchan_transport > 6 )
{
sba_order = 3;
sba_order = SBA_HOA3_ORDER;
}
else if ( nchan_transport > 4 )
{
sba_order = 2;
sba_order = SBA_HOA2_ORDER;
}
return ( sba_order );
......@@ -276,7 +291,7 @@ int16_t ivas_sba_get_nchan_metadata(
{
int16_t nb_channels;
if ( sba_order == 1 )
if ( sba_order == SBA_FOA_ORDER )
{
nb_channels = FOA_CHANNELS;
}
......@@ -289,6 +304,31 @@ int16_t ivas_sba_get_nchan_metadata(
return ( nb_channels );
}
/*-------------------------------------------------------------------*
* ivas_sba_get_spar_hoa_md_flag()
*
* Get the flag to code SPAR HOA MD for all band
*-------------------------------------------------------------------*/
/*! r: flag indicating to code SPAR HOA MD for all bands */
int16_t ivas_sba_get_spar_hoa_md_flag(
const int16_t sba_order, /* i : Ambisonic (SBA) order */
const int32_t ivas_total_brate /* i : IVAS total bitrate */
)
{
int16_t spar_hoa_md_flag = 0;
if ( sba_order > 1 && ivas_total_brate >= IVAS_256k )
{
spar_hoa_md_flag = 1;
}
else
{
spar_hoa_md_flag = 0;
}
return spar_hoa_md_flag;
}
/*-------------------------------------------------------------------*
* ivas_sba_zero_vert_comp()
......
......@@ -37,15 +37,12 @@
#include "ivas_prot.h"
#include "rom_com.h"
#include <math.h>
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
#include <assert.h>
#endif
#ifdef DEBUGGING
#include "debug.h"
#endif
#include "wmops.h"
#ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT
/*-------------------------------------------------------------------
* sns_compute_scf()
......@@ -56,7 +53,7 @@
void sns_compute_scf(
float spectrum[],
const PsychoacousticParameters *pPsychParams,
const int16_t L_frame, /* TODO: this parameter is obsolete, since pPsychParams->nBins is used anyway */
const int16_t L_frame,
float *scf )
{
int16_t i, n, k;
......@@ -212,7 +209,6 @@ void sns_compute_scf(
return;
}
#endif
/*-------------------------------------------------------------------
* sns_interpolate_scalefactors()
......
......@@ -75,6 +75,7 @@
* Static functions declaration
*------------------------------------------------------------------------------------------*/
static void ivas_get_pred_coeffs( float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], float ppPred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], float ppDM_Fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS], const int16_t in_chans, const int16_t start_band, const int16_t end_band, const int16_t active_w, const int16_t dtx_vad, const int16_t from_dirac );
static void ivas_reorder_array( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS], const int16_t in_chans, const int16_t order[IVAS_SPAR_MAX_CH], float ***mixer_mat, const int16_t start_band, const int16_t end_band );
......@@ -311,7 +312,7 @@ void ivas_spar_config(
const int16_t sid_format /* i : IVAS format indicator from SID frame */
)
{
if ( ivas_total_brate == IVAS_SID_5k )
if ( ivas_total_brate == IVAS_SID_5k2 )
{
if ( sid_format == SID_SBA_1TC )
{
......@@ -324,7 +325,7 @@ void ivas_spar_config(
}
else
{
*nchan_transport = ivas_get_spar_num_TCs( ivas_total_brate, sba_order );
*nchan_transport = ivas_get_sba_num_TCs( ivas_total_brate, sba_order );
}
*nCPE = ( *nchan_transport > 1 ) ? ( *nchan_transport + 1 ) >> 1 : 0;
......@@ -333,7 +334,7 @@ void ivas_spar_config(
if ( *nchan_transport == 1 )
{
/* map SPAR SID bitrate to SPAR active bitrate */
if ( ivas_total_brate == IVAS_SID_5k )
if ( ivas_total_brate == IVAS_SID_5k2 )
{
ivas_total_brate = IVAS_32k;
}
......@@ -409,20 +410,24 @@ int16_t ivas_get_spar_table_idx(
/*-------------------------------------------------------------------*
* ivas_get_spar_num_TCs()
* ivas_get_sba_num_TCs()
*
* Return number of TCs in SPAR
* Return number of TCs in SBA format
*-------------------------------------------------------------------*/
/*! r: number of transport channels */
int16_t ivas_get_spar_num_TCs(
int16_t ivas_get_sba_num_TCs(
const int32_t ivas_total_brate, /* i : IVAS total bitrate */
const int16_t sba_order /* i : Ambisonic (SBA) order */
)
{
int16_t table_idx, nchan_transport;
if ( ivas_total_brate == IVAS_SID_5k )
if ( ivas_total_brate == IVAS_SID_5k2 )
{
nchan_transport = 1;
}
else if ( ivas_sba_mode_select( ivas_total_brate ) == SBA_MODE_DIRAC )
{
nchan_transport = 1;
}
......@@ -444,7 +449,7 @@ int16_t ivas_get_spar_num_TCs(
*-----------------------------------------------------------------------------------------*/
static void ivas_get_pred_coeffs(
float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float ppPred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
float ppDM_Fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
const int16_t in_chans,
......@@ -469,7 +474,7 @@ static void ivas_get_pred_coeffs(
set_zero( pPred_temp, IVAS_MAX_NUM_BANDS );
for ( k = start_band; k < end_band; k++ )
{
div_factor[k] = max( 1e-20f, pppCov_mat_re[0][0][k] );
div_factor[k] = max( 1e-20f, cov_real[0][0][k] );
div_factor[k] = 1 / div_factor[k];
}
......@@ -477,7 +482,7 @@ static void ivas_get_pred_coeffs(
{
for ( k = start_band; k < end_band; k++ )
{
ppPred_coeffs_re[i][k] = pppCov_mat_re[i + 1][0][k] * div_factor[k];
ppPred_coeffs_re[i][k] = cov_real[i + 1][0][k] * div_factor[k];
IVAS_CALCULATE_SQ_ABS_N( ppPred_coeffs_re[i][k], abs_value );
......@@ -515,7 +520,7 @@ static void ivas_get_pred_coeffs(
{
for ( k = start_band; k < end_band; k++ )
{
IVAS_CALCULATE_SQ_ABS_N( pppCov_mat_re[i][0][k], abs_value );
IVAS_CALCULATE_SQ_ABS_N( cov_real[i][0][k], abs_value );
dm_alpha[k] += abs_value;
}
}
......@@ -531,7 +536,7 @@ static void ivas_get_pred_coeffs(
{
for ( k = start_band; k < end_band; k++ )
{
dm_v_re[i][k] = pppCov_mat_re[i + 1][0][k] * div_factor[k];
dm_v_re[i][k] = cov_real[i + 1][0][k] * div_factor[k];
}
}
......@@ -554,7 +559,7 @@ static void ivas_get_pred_coeffs(
{
float re;
IVAS_RMULT_FLOAT( pppCov_mat_re[j + 1][k][b], dm_v_re[k - 1][b], re );
IVAS_RMULT_FLOAT( cov_real[j + 1][k][b], dm_v_re[k - 1][b], re );
real[j] += re;
}
}
......@@ -566,7 +571,7 @@ static void ivas_get_pred_coeffs(
dm_beta_re += re;
}
dm_w = pppCov_mat_re[0][0][b];
dm_w = cov_real[0][0][b];
den_f = max( dm_w, 1e-20f );
passive_g = dm_alpha[b] / den_f;
......@@ -577,7 +582,7 @@ static void ivas_get_pred_coeffs(
for ( k = 1; k < in_chans; k++ )
{
dm_y += pppCov_mat_re[k][k][b];
dm_y += cov_real[k][k][b];
}
den_f = max( dm_y, 1e-20f );
den_f = max( den_f, w_norm_fac * dm_w );
......@@ -630,7 +635,7 @@ static void ivas_get_pred_coeffs(
*-----------------------------------------------------------------------------------------*/
static void ivas_get_Wscaling_factor(
float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
float ***mixer_mat,
const int16_t start_band,
......@@ -663,9 +668,9 @@ static void ivas_get_Wscaling_factor(
{
float Gw_sq, g_sq = 0;
ivas_calc_post_pred_per_band( pppCov_mat_re, mixer_mat, num_ch, pNum_dmx[b * bands_bw], b, postpred_cov_re );
ivas_calc_post_pred_per_band( cov_real, mixer_mat, num_ch, pNum_dmx[b * bands_bw], b, postpred_cov_re );
Gw_sq = pppCov_mat_re[0][0][b] / max( postpred_cov_re[0][0], IVAS_FLT_EPS );
Gw_sq = cov_real[0][0][b] / max( postpred_cov_re[0][0], IVAS_FLT_EPS );
for ( ch = 0; ch < num_ch - 1; ch++ )
{
......@@ -857,7 +862,7 @@ static void ivas_reorder_array(
*-----------------------------------------------------------------------------------------*/
static void ivas_calc_post_pred_per_band(
float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float ***mixer_mat,
const int16_t num_ch,
const int16_t num_dmx,
......@@ -894,7 +899,7 @@ static void ivas_calc_post_pred_per_band(
temp_mat[i][j] = 0;
for ( k = 0; k < num_ch; k++ )
{
IVAS_RMULT_FLOAT( pppCov_mat_re[i][k][band_idx], dmx_mat_conj[k][j], tmp_re );
IVAS_RMULT_FLOAT( cov_real[i][k][band_idx], dmx_mat_conj[k][j], tmp_re );
temp_mat[i][j] += tmp_re;
}
}
......@@ -907,7 +912,6 @@ static void ivas_calc_post_pred_per_band(
{
for ( k = 0; k < num_ch; k++ )
{
IVAS_RMULT_FLOAT( mixer_mat[i][k][band_idx], temp_mat[k][j], tmp_re );
postpred_cov_re[i][j] += tmp_re;
}
......@@ -1208,6 +1212,7 @@ static void ivas_calc_c_coeffs_per_band(
else
{
ivas_calc_mat_inv( cov_dd_re, num_dmx - 1, cov_dd_re_inv );
for ( i = 0; i < num_ch - num_dmx; i++ )
{
for ( j = 0; j < num_dmx - 1; j++ )
......@@ -1235,7 +1240,7 @@ static void ivas_calc_c_coeffs_per_band(
void ivas_calc_c_p_coeffs(
ivas_spar_md_t *pSparMd,
float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
const int16_t i_ts,
float ***mixer_mat,
const int16_t num_ch,
......@@ -1250,7 +1255,8 @@ void ivas_calc_c_p_coeffs(
if ( num_dmx != num_ch )
{
ivas_calc_post_pred_per_band( pppCov_mat_re, mixer_mat, num_ch, num_dmx, band_idx, postpred_cov_re );
ivas_calc_post_pred_per_band( cov_real, mixer_mat, num_ch, num_dmx, band_idx, postpred_cov_re );
if ( num_dmx != 1 )
{
ivas_calc_c_coeffs_per_band( pSparMd, i_ts, postpred_cov_re, num_ch, num_dmx, band_idx, dtx_vad );
......@@ -1384,6 +1390,7 @@ static void ivas_get_mat_cofactor(
*
* Calculate Invert of a matrix
*-----------------------------------------------------------------------------------------*/
static void ivas_calc_mat_inv(
float in_re[MAX_MAT_DIM][MAX_MAT_DIM],
const int16_t dim,
......@@ -1483,6 +1490,7 @@ static void ivas_calc_mat_inv(
*
* Check if matrix is invertible or not by checking if determinant is 0 or very close to 0
*-----------------------------------------------------------------------------------------*/
static int16_t ivas_is_mat_inv(
float in_re[MAX_MAT_DIM][MAX_MAT_DIM],
const int16_t dim )
......@@ -1520,7 +1528,7 @@ static int16_t ivas_is_mat_inv(
*-----------------------------------------------------------------------------------------*/
void ivas_compute_spar_params(
float *pppCov_mat_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float *cov_real[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH],
float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS],
const int16_t i_ts,
float ***mixer_mat,
......@@ -1538,7 +1546,7 @@ void ivas_compute_spar_params(
float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS];
int16_t b, i, ndm;
ivas_get_pred_coeffs( pppCov_mat_re, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, dtx_vad, from_dirac );
ivas_get_pred_coeffs( cov_real, pred_coeffs_re, dm_fv_re, num_ch, start_band, end_band, active_w, dtx_vad, from_dirac );
#ifdef SPAR_HOA_DBG
/*fprintf(stderr, "\n\n Prediction Coefficients:\n");
......@@ -1569,7 +1577,7 @@ void ivas_compute_spar_params(
fprintf(stderr, "\n\n");*/
#endif
ivas_get_Wscaling_factor( pppCov_mat_re, pred_coeffs_re, mixer_mat, start_band, end_band, dtx_vad, num_ch,
ivas_get_Wscaling_factor( cov_real, pred_coeffs_re, mixer_mat, start_band, end_band, dtx_vad, num_ch,
hSparCfg->num_dmx_chans_per_band, bands_bw, active_w, pWscale );
for ( b = start_band; b < end_band; b++ )
......@@ -1592,7 +1600,7 @@ void ivas_compute_spar_params(
if ( ndm != num_ch )
{
ivas_calc_c_p_coeffs( hSparMd, pppCov_mat_re, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1, 0 );
ivas_calc_c_p_coeffs( hSparMd, cov_real, i_ts, mixer_mat, num_ch, ndm, b, dtx_vad, 1, 0 );
#ifdef SPAR_HOA_DBG
/* if (b == 0) */
......@@ -1618,7 +1626,6 @@ void ivas_compute_spar_params(
}
}
return;
}
......@@ -1661,8 +1668,8 @@ void ivas_get_spar_md_from_dirac(
remix_order = remix_order_set[hSpar_md_cfg->remix_unmix_order];
num_ch = 2 * order + 2;
hoa2_ch = 6;
num_ch = ivas_sba_get_nchan_metadata( order );
hoa2_ch = ivas_sba_get_nchan_metadata( SBA_HOA2_ORDER );
foa_ch = FOA_CHANNELS;
diff_norm_order1 = 3.0f;
diff_norm_order2 = 5.0f;
......@@ -1681,6 +1688,7 @@ void ivas_get_spar_md_from_dirac(
{
float P_norm[3];
int16_t idx;
ndm = hSpar_md_cfg->num_dmx_chans_per_band[start_band - 1];
P_norm[0] = 0.0f;
for ( i = 0; i < max( 0, foa_ch - ndm ); i++ )
......@@ -1731,10 +1739,6 @@ void ivas_get_spar_md_from_dirac(
/*SPAR from DirAC*/
set_f( response_avg, 0.0f, MAX_OUTPUT_CHANNELS );
set_f( hSpar_md->band_coeffs[band + i_ts * IVAS_MAX_NUM_BANDS].pred_re, 0.0f, IVAS_SPAR_MAX_CH - 1 );
set_f( &hSpar_md->band_coeffs[band + i_ts * IVAS_MAX_NUM_BANDS].C_re[0][0], 0.0f, ( IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS ) * ( IVAS_SPAR_MAX_DMX_CHS - 1 ) );
set_f( &hSpar_md->band_coeffs[band + i_ts * IVAS_MAX_NUM_BANDS].P_re[0], 0.0f, ( IVAS_SPAR_MAX_CH - 1 ) );
if ( n_ts > 1 )
{
ivas_dirac_dec_get_response( (int16_t) azi_dirac[band][i_ts], (int16_t) ele_dirac[band][i_ts], response_avg, order );
......@@ -1752,7 +1756,7 @@ void ivas_get_spar_md_from_dirac(
int16_t num_ch_order, hoa2_ch_order;
num_ch_order = ivas_sba_get_nchan( order, 0 );
hoa2_ch_order = 9;
hoa2_ch_order = ivas_sba_get_nchan( SBA_HOA2_ORDER, 0 );
for ( ch = 0; ch < num_ch_order; ch++ )
{
......@@ -2107,17 +2111,7 @@ void ivas_spar_set_bitrate_config(
pSpar_md_cfg->agc_bits_ch_idx = ivas_spar_br_table_consts[table_idx].agc_bits_ch_idx;
ivas_spar_get_uniform_quant_strat( pSpar_md_cfg, table_idx );
if ( pSpar_md_cfg->quant_strat->C.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->C.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->PR.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->PR.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->P_c.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->P_c.q_levels[1] == 0 || pSpar_md_cfg->quant_strat->P_r.q_levels[0] == 0 || pSpar_md_cfg->quant_strat->P_r.q_levels[1] == 0 )
{
pSpar_md_cfg->gen_bs = 0;
}
else
{
if ( 0 != pSpar_md_cfg->gen_bs )
{
pSpar_md_cfg->quant_strat_bits = ivas_get_bits_to_encode( MAX_QUANT_STRATS );
}
}
/* BLOCK: getEntropyCoderModels */
......@@ -2129,18 +2123,19 @@ void ivas_spar_set_bitrate_config(
ivas_total_brate = ivas_spar_br_table_consts[table_idx].ivas_total_brate;
sba_order = ivas_spar_br_table_consts[table_idx].sba_order;
ivas_get_spar_table_idx( ivas_total_brate, sba_order, ivas_spar_br_table_consts[table_idx].bwidth, &code, &length );
ivas_get_spar_table_idx( ivas_total_brate, sba_order, ivas_spar_br_table_consts[table_idx].bwidth, &length, &code );
for ( i = 0; i < pSpar_md_cfg->nchan_transport; i++ )
{
total_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].evs_brs[i][0] / FRAMES_PER_SEC );
max_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].evs_brs[i][1] / FRAMES_PER_SEC );
total_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].core_brs[i][0] / FRAMES_PER_SEC );
max_bits += (int16_t) ( ivas_spar_br_table_consts[table_idx].core_brs[i][1] / FRAMES_PER_SEC );
}
pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - total_bits;
pSpar_md_cfg->tgt_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - total_bits;
pSpar_md_cfg->max_bits_per_blk = (int16_t) ( ivas_total_brate / FRAMES_PER_SEC ) - IVAS_FORMAT_SIGNALING_NBITS_SBA - SBA_PLANAR_BITS - SBA_ORDER_BITS - length - max_bits;
md_coding_bits_header = SPAR_NUM_CODING_STRAT_BITS + pSpar_md_cfg->quant_strat_bits;
pSpar_md_cfg->tgt_bits_per_blk -= md_coding_bits_header;
pSpar_md_cfg->max_bits_per_blk -= md_coding_bits_header;
......@@ -2149,9 +2144,11 @@ void ivas_spar_set_bitrate_config(
pSpar_md_cfg->tgt_bits_per_blk += md_coding_bits_header;
pSpar_md_cfg->max_bits_per_blk += md_coding_bits_header;
return;
}
#ifdef FIX_I1_113
/*-----------------------------------------------------------------------------------------*
* Function ivas_spar_bitrate_dist()
......@@ -2159,7 +2156,6 @@ void ivas_spar_set_bitrate_config(
* Set SPAR bitrate distribution
*-----------------------------------------------------------------------------------------*/
// this function is not currently used but it is kept for future use
void ivas_spar_bitrate_dist(
int32_t core_brates_act[], /* o : bitrates per core-coder */
const int16_t nAvailBits, /* i : number of available bits */
......@@ -2179,7 +2175,7 @@ void ivas_spar_bitrate_dist(
sum_core_act_bits = 0;
for ( i = 0; i < nchan_transport; i++ )
{
core_bits_act[i] = (int16_t) ( ivas_spar_br_table_consts[table_idx].evs_brs[i][0] / FRAMES_PER_SEC );
core_bits_act[i] = (int16_t) ( ivas_spar_br_table_consts[table_idx].core_brs[i][0] / FRAMES_PER_SEC );
sum_core_act_bits += core_bits_act[i];
}
......@@ -2191,7 +2187,7 @@ void ivas_spar_bitrate_dist(
{
for ( i = 0; i < nchan_transport; i++ )
{
core_range_bits[i] = (int16_t) ( ( ivas_spar_br_table_consts[table_idx].evs_brs[i][2] - ivas_spar_br_table_consts[table_idx].evs_brs[i][0] ) / FRAMES_PER_SEC );
core_range_bits[i] = (int16_t) ( ( ivas_spar_br_table_consts[table_idx].core_brs[i][2] - ivas_spar_br_table_consts[table_idx].core_brs[i][0] ) / FRAMES_PER_SEC );
core_bits_act[i] += min( residual_bits, core_range_bits[i] );
residual_bits -= core_range_bits[i];
......@@ -2205,7 +2201,7 @@ void ivas_spar_bitrate_dist(
{
for ( i = 0; i < nchan_transport; i++ )
{
core_range_bits[i] = (int16_t) ( ( ivas_spar_br_table_consts[table_idx].evs_brs[i][0] - ivas_spar_br_table_consts[table_idx].evs_brs[i][1] ) / FRAMES_PER_SEC );
core_range_bits[i] = (int16_t) ( ( ivas_spar_br_table_consts[table_idx].core_brs[i][0] - ivas_spar_br_table_consts[table_idx].core_brs[i][1] ) / FRAMES_PER_SEC );
}
overflow_bits = -residual_bits;
......
......@@ -42,90 +42,49 @@
#include <assert.h>
#include "wmops.h"
/*-----------------------------------------------------------------------------------------*
* Function ivas_limit_values()
*
* Limit values within given range
*-----------------------------------------------------------------------------------------*/
static void ivas_limit_values(
float **ppValues,
const float min_value,
const float max_value,
const int16_t dim1,
const int16_t dim2 )
{
int16_t i, j;
for ( i = 0; i < dim1; i++ )
{
for ( j = 0; j < dim2; j++ )
{
ppValues[i][j] = max( min_value, min( ppValues[i][j], max_value ) );
}
}
return;
}
/*-----------------------------------------------------------------------------------------*
* Function ivas_quantise_real_values()
*
* Quantize real values
*-----------------------------------------------------------------------------------------*/
void ivas_quantise_real_values(
float **values,
const float *values,
const int16_t q_levels,
const float min_value,
const float max_value,
int16_t **index,
float **quant,
const int16_t dim1,
const int16_t dim2 )
int16_t *index,
float *quant,
const int16_t dim )
{
int16_t i, j;
int16_t i;
float q_step, one_by_q_step;
if ( q_levels == 1 )
{
for ( i = 0; i < dim1; i++ )
for ( i = 0; i < dim; i++ )
{
for ( j = 0; j < dim2; j++ )
{
quant[i][j] = 0;
index[i][j] = 0;
}
quant[i] = 0;
index[i] = 0;
}
}
else if ( q_levels && max_value != min_value )
{
ivas_limit_values( values, min_value, max_value, dim1, dim2 );
q_step = ( max_value - min_value ) / ( q_levels - 1 );
one_by_q_step = ( q_levels - 1 ) / ( max_value - min_value );
for ( i = 0; i < dim1; i++ )
float val;
for ( i = 0; i < dim; i++ )
{
for ( j = 0; j < dim2; j++ )
{
index[i][j] = (int16_t) round( one_by_q_step * values[i][j] );
quant[i][j] = index[i][j] * q_step;
}
val = max( min_value, min( values[i], max_value ) );
index[i] = (int16_t) round( one_by_q_step * val );
quant[i] = index[i] * q_step;
}
}
else
{
for ( i = 0; i < dim1; i++ )
for ( i = 0; i < dim; i++ )
{
for ( j = 0; j < dim2; j++ )
{
quant[i][j] = values[i][j];
}
quant[i] = values[i];
}
}
return;
}
......@@ -386,7 +345,6 @@ void ivas_clear_band_coeff_idx(
for ( i = 0; i < num_bands; i++ )
{
set_s( pband_coeff_idx[i].pred_index_re, 0, ( IVAS_SPAR_MAX_CH - 1 ) );
set_s( pband_coeff_idx[i].drct_index_re, 0, IVAS_SPAR_MAX_C_COEFF );
set_s( pband_coeff_idx[i].decd_index_re, 0, ( IVAS_SPAR_MAX_CH - 1 ) );
}
......