From c0dff25b0d0e0f27e3f019bcc032842121a65bea Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Dec 2022 18:52:10 +0100 Subject: [PATCH 1/7] - formatting, comments, editorial improvements - remove unused file lib_debug/segsnr.c - remove duplicated code in renderer.c - updates for the WMC instrumentation - do not use a function as an array index, e.g. vector[min(a,b)]; --- Workspace_msvc/lib_debug.vcxproj | 3 +- apps/renderer.c | 19 --- lib_com/bitstream.c | 5 +- lib_com/ivas_cnst.h | 19 ++- lib_com/ivas_mdct_imdct.c | 5 +- lib_com/ivas_prot.h | 135 +++++++++++--------- lib_com/ivas_sba_config.c | 2 +- lib_com/prot.h | 21 +-- lib_debug/segsnr.c | 103 --------------- lib_dec/igf_dec.c | 15 ++- lib_dec/ivas_dirac_dec_binaural_functions.c | 13 +- lib_dec/ivas_qmetadata_dec.c | 5 +- lib_dec/ivas_stereo_cng_dec.c | 1 + lib_dec/ivas_vbap.c | 11 +- lib_enc/cod_tcx.c | 7 +- lib_enc/enc_pit_exc.c | 4 +- lib_enc/ivas_agc_enc.c | 3 +- lib_enc/ivas_core_pre_proc_front.c | 5 +- lib_enc/ivas_qmetadata_enc.c | 27 ++-- lib_rend/ivas_render_config.c | 8 ++ lib_rend/ivas_rotation.c | 59 +++++---- lib_rend/lib_rend.c | 4 +- 22 files changed, 199 insertions(+), 275 deletions(-) delete mode 100644 lib_debug/segsnr.c diff --git a/Workspace_msvc/lib_debug.vcxproj b/Workspace_msvc/lib_debug.vcxproj index 5dc36d4633..59221f7427 100644 --- a/Workspace_msvc/lib_debug.vcxproj +++ b/Workspace_msvc/lib_debug.vcxproj @@ -145,7 +145,6 @@ - @@ -166,4 +165,4 @@ - + \ No newline at end of file diff --git a/apps/renderer.c b/apps/renderer.c index 506830002c..486ed42757 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -62,25 +62,6 @@ #include #include -#ifndef count_malloc -#ifdef RAM_COUNTING_TOOL -#define count_malloc( n1 ) MALLOC_FCT_CALL( n1 ) -#define count_calloc( n1, n2 ) CALLOC_FCT_CALL( n1, n2 ) -#define count_free( ptr ) FREE_FCT_CALL( ptr ) -#else -#define count_malloc( n1 ) malloc( n1 ) -#define count_calloc( n1, n2 ) calloc( n1, n2 ) -#define count_free( ptr ) free( ptr ) -#endif -#endif - -#ifndef min -#define min( x, y ) ( ( x ) < ( y ) ? ( x ) : ( y ) ) -#endif - -#ifndef max -#define max( x, y ) ( ( x ) > ( y ) ? ( x ) : ( y ) ) -#endif #define RENDERER_MAX_CLI_ARG_LENGTH ( FILENAME_MAX ) #define RENDERER_MAX_METADATA_LENGTH 8192 diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 34c68d2540..34d18b4f20 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2946,14 +2946,17 @@ void evs_dec_previewFrame( void dtx_read_padding_bits( DEC_CORE_HANDLE st, - int16_t num_bits ) + const 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; + + return; } #undef WMC_TOOL_MAN diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index 9b778c9f6c..fc3079c51f 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -107,8 +107,8 @@ typedef enum AUDIO_CONFIG_ISM2, /* ISM2 */ AUDIO_CONFIG_ISM3, /* ISM3 */ AUDIO_CONFIG_ISM4, /* ISM4 */ - AUDIO_CONFIG_MASA1, /* MASA1 */ - AUDIO_CONFIG_MASA2, /* MASA2 */ + AUDIO_CONFIG_MASA1, /* MASA1 */ // TBV: seems not to be used + AUDIO_CONFIG_MASA2, /* MASA2 */ // TBV: seems not to be used AUDIO_CONFIG_EXTERNAL /* external renderer */ } AUDIO_CONFIG; @@ -191,8 +191,6 @@ typedef enum #define IVAS_MAX_SBA_ORDER 3 /* Maximum supported Ambisonics order */ -#define IVAS_LIMITER_THRESHOLD 32729 /* -0.01 dBFS */ -#define IVAS_LIMITER_ATTACK_SECONDS 0.005f #define IVAS_NUM_SUPPORTED_FS 3 /* number of supported sampling-rates in IVAS */ /*----------------------------------------------------------------------------------* @@ -1378,7 +1376,7 @@ typedef enum * TD Binaural Object renderer *----------------------------------------------------------------------------------*/ -#define MAX_NUM_TDREND_CHANNELS 16 /* max. number of channels in TD renderer (objects or loudspeaker channels) */ +#define MAX_NUM_TDREND_CHANNELS MAX_CICP_CHANNELS /* max. number of channels in TD renderer (objects or loudspeaker channels) */ #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 */ @@ -1471,8 +1469,6 @@ typedef enum #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 /*----------------------------------------------------------------------------------* @@ -1593,6 +1589,15 @@ typedef enum #define SPAR_DIRAC_DTX_BANDS ( SPAR_DTX_BANDS + DIRAC_DTX_BANDS ) #define CLDFB_PAR_WEIGHT_START_BAND 7 + +/*----------------------------------------------------------------------------------* + * Limiter constants + *----------------------------------------------------------------------------------*/ + +#define IVAS_LIMITER_THRESHOLD 32729 /* -0.01 dBFS */ +#define IVAS_LIMITER_ATTACK_SECONDS 0.005f + + #endif /* clang-format on */ /* IVAS_CNST_H */ diff --git a/lib_com/ivas_mdct_imdct.c b/lib_com/ivas_mdct_imdct.c index 036f89201f..06b393acb3 100644 --- a/lib_com/ivas_mdct_imdct.c +++ b/lib_com/ivas_mdct_imdct.c @@ -44,13 +44,14 @@ /*------------------------------------------------------------------------------------------* * Local constants *------------------------------------------------------------------------------------------*/ + #define IVAS_IMDCT_SCALING_GAIN 2115.165304808f /*-----------------------------------------------------------------------------------------* * Function ivas_tda() * - * Time domain alias implementation + * Time domain aliasing *-----------------------------------------------------------------------------------------*/ void ivas_tda( @@ -67,6 +68,8 @@ void ivas_tda( pOut[i] = -pIn[len_by_2 - i - 1] + pIn[len_by_2 + i]; pOut[len_by_2 + i] = pIn[length * 2 - i - 1] + pIn[length + i]; } + + return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 120042c891..2c265afda1 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -105,28 +105,6 @@ 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 */ -#ifdef SBA_BR_SWITCHING_2 - , int16_t sba_order -#endif -); -#endif -#ifdef SBA_BR_SWITCHING_2 -ivas_error ivas_spar_md_enc_init -( - ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ -); -#endif ivas_error ivas_sba_enc_reconfigure( Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ ); @@ -215,8 +193,8 @@ ivas_error pre_proc_front_ivas( const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ - const int16_t front_vad_dtx_flag /* i : front-VAD DTX flag to overwrite VAD decision*/ - ,const int32_t ivas_total_brate /* i : IVAS total bitrate */ + const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ + const int32_t ivas_total_brate /* i : IVAS total bitrate */ ); ivas_error pre_proc_ivas( @@ -735,6 +713,39 @@ void ivas_imdft( const int16_t length /* i : signal length */ ); +void TonalMdctConceal_create_concealment_noise( + float concealment_noise[L_FRAME48k], + CPE_DEC_HANDLE hCPE, + const int16_t L_frameTCX, + const int16_t L_frame, + const int16_t idchan, + const int16_t subframe_idx, + const int16_t core, + const float crossfade_gain, + const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode +); + +void TonalMdctConceal_whiten_noise_shape( + Decoder_State *st, + const int16_t L_frame, + const TONALMDCTCONC_NOISE_SHAPE_WHITENING_MODE +); + +/*! r: IGF start line */ +int16_t get_igf_startline( + Decoder_State *st, /* i : decoder state */ + const int16_t L_frame, /* i : length of the frame */ + const int16_t L_frameTCX /* i : full band frame length */ +); + +float rand_triangular_signed( + int16_t *seed ); + +void dtx_read_padding_bits( + DEC_CORE_HANDLE st, + const int16_t num_bits +); + /*----------------------------------------------------------------------------------* * ISm prototypes @@ -3045,13 +3056,12 @@ void ivas_dirac_param_est_enc( float data_f[][L_FRAME48k], float **pp_fr_real, float **pp_fr_imag, - const int16_t input_frame - , + const int16_t input_frame, const SBA_MODE sba_mode ); /*----------------------------------------------------------------------------------* - * SBA mode prototypes + * SBA format prototypes *----------------------------------------------------------------------------------*/ /*! r: SBA format mode */ @@ -3069,9 +3079,30 @@ void ivas_sba_config( int16_t *nCPE, /* o : number of CPEs */ int16_t *element_mode /* o : element mode of the core coder */ ); + +ivas_error ivas_sba_enc_reconfigure( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + #ifdef SBA_BR_SWITCHING -ivas_error ivas_sba_dec_reinit( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +ivas_error ivas_sba_enc_reinit( + Encoder_Struct *st_ivas /* i/o: IVAS encoder structure */ +); + +int16_t get_sba_reinit_flag( + int32_t ivas_total_bitrate, /* i : Current bitrate */ + int32_t last_ivas_total_brate /* i : Previous bitrate */ +#ifdef SBA_BR_SWITCHING_2 + , const int16_t sba_order +#endif +); +#endif +#ifdef SBA_BR_SWITCHING_2 +ivas_error ivas_spar_md_enc_init +( + ivas_spar_md_enc_state_t *hMdEnc, /* o : MD encoder handle */ + const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ); #endif @@ -3079,6 +3110,13 @@ ivas_error ivas_sba_dec_reconfigure( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef SBA_BR_SWITCHING +ivas_error ivas_sba_dec_reinit( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif + + void ivas_init_dec_get_num_cldfb_instances( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ int16_t *numCldfbAnalyses, /* o : number of CLDFB analysis instances */ @@ -4863,8 +4901,7 @@ void computeReferencePower_enc( float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i : Imag part of input signal */ 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 int16_t num_freq_bands, /* i : Number of frequency bands */ const SBA_MODE sba_mode /* i : SBA mode */ ); @@ -5301,6 +5338,7 @@ ivas_error ivas_render_config_init_from_rom( const int16_t room_flag_on /* i : room effect on/off flag */ ); + /*----------------------------------------------------------------------------------* * Reverberator *----------------------------------------------------------------------------------*/ @@ -5499,7 +5537,10 @@ void ivas_reverb_get_hrtf_set_properties( ); -/* Orientation tracking */ +/*----------------------------------------------------------------------------------* + * Orientation tracking + *----------------------------------------------------------------------------------*/ + void ivas_orient_trk_Init( ivas_orient_trk_state_t *pOTR ); @@ -5527,37 +5568,7 @@ ivas_error ivas_orient_trk_GetTrackedOrientation( float *roll ); -void TonalMdctConceal_create_concealment_noise( - float concealment_noise[L_FRAME48k], - CPE_DEC_HANDLE hCPE, - const int16_t L_frameTCX, - const int16_t L_frame, - const int16_t idchan, - const int16_t subframe_idx, - const int16_t core, - const float crossfade_gain, - const TONALMDCTCONC_NOISE_GEN_MODE noise_gen_mode -); - -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 */ diff --git a/lib_com/ivas_sba_config.c b/lib_com/ivas_sba_config.c index 133bf3886d..a0e04edf67 100644 --- a/lib_com/ivas_sba_config.c +++ b/lib_com/ivas_sba_config.c @@ -84,7 +84,7 @@ int16_t get_sba_reinit_flag( int32_t last_ivas_total_brate /* i : Previous bitrate */ #ifdef SBA_BR_SWITCHING_2 , - int16_t sba_order + const int16_t sba_order #endif ) { diff --git a/lib_com/prot.h b/lib_com/prot.h index 760571cb46..03e3ccb8ce 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -7867,17 +7867,18 @@ void coder_tcx( ); void coder_tcx_post( - Encoder_State *st, /* i/o: decoder memory state */ - float *A, - const float *Ai ); + Encoder_State *st, /* i/o: encoder memory state */ + float *A, /* o : Quantized LPC coefficients */ + const float *Ai /* i : Unquantized (interpolated) LPC coefficients */ +); void decoder_tcx( - Decoder_State *st, /* i/o: coder memory state */ - int16_t prm[], /* i : parameters */ - float A[], /* i : coefficients NxAz[M+1] */ - Word16 Aind[], /* i : frame-independent coefficients Az[M+1]*/ - float synth[], /* i/o: synth[-M..lg] */ - float synthFB[], + Decoder_State *st, /* i/o: coder memory state */ + int16_t prm[], /* i : parameters */ + float A[], /* i : coefficients NxAz[M+1] */ + Word16 Aind[], /* i : frame-independent coefficients Az[M+1]*/ + float synth[], /* i/o: synth[-M..lg] */ + float synthFB[], /* i/o: encoder memory state */ const int16_t bfi, /* i : Bad frame indicator */ const int16_t frame_cnt, /* i : frame counter in the super_frame */ const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ @@ -7981,7 +7982,7 @@ void writeTCXparam( const int16_t pre_past_flag ); void enc_prm_rf( - Encoder_State *st, /* i/o: decoder memory state */ + Encoder_State *st, /* i/o: encoder memory state */ const int16_t rf_frame_type, const int16_t fec_offset ); diff --git a/lib_debug/segsnr.c b/lib_debug/segsnr.c deleted file mode 100644 index 561a4e239d..0000000000 --- a/lib_debug/segsnr.c +++ /dev/null @@ -1,103 +0,0 @@ -/****************************************************************************************************** - - (C) 2022 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository. All Rights Reserved. - - This software is protected by copyright law and by international treaties. - The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, - Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., - Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, - Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other - contributors to this repository retain full ownership rights in their respective contributions in - the software. This notice grants no license of any kind, including but not limited to patent - license, nor is any license granted by implication, estoppel or otherwise. - - Contributors are required to enter into the IVAS codec Public Collaboration agreement before making - contributions. - - This software is provided "AS IS", without any express or implied warranties. The software is in the - development stage. It is intended exclusively for experts who have experience with such software and - solely for the purpose of inspection. All implied warranties of non-infringement, merchantability - and fitness for a particular purpose are hereby disclaimed and excluded. - - Any dispute, controversy or claim arising under or in relation to providing this software shall be - submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in - accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and - the United Nations Convention on Contracts on the International Sales of Goods. - -*******************************************************************************************************/ - -#include -#ifdef DEBUGGING -#include "debug.h" -#endif -#include "wmops.h" -#include -#include "options.h" -#include "prot.h" - -#define WMC_TOOL_MAN - -#ifdef OUTPUT_SNR -/*_____________________________________________________________________ - | | - | FUNCTION NAME segsnr | - | Computes the segmential signal-to-noise ratio between the | - | signal x and its estimate xe of length n samples. The segment | - | length is nseg samples. | - | - | INPUT - | x[0:n-1] Signal of n samples. - | xe[0:n-1] Estimated signal of n samples. - | n Signal length. - | nseg Segment length, must be a submultiple of n. - | - | RETURN VALUE - | snr Segmential signal to noise ratio in dB. - |_____________________________________________________________________| -*/ - -float segsnr( float x[], float xe[], int16_t n, int16_t nseg ) -{ - float snr = 0.0f; - float signal, noise, error, fac; - int16_t i, j; - LOOP( 1 ); - for ( i = 0; i < n; i += nseg ) - { - signal = 1e-6f; - MOVE( 2 ); - noise = 1e-6f; - LOOP( 1 ); - for ( j = 0; j < nseg; j++ ) - { - signal += ( *x ) * ( *x ); - MAC( 1 ); - error = *x++ - *xe++; - ADD( 1 ); - noise += error * error; - MAC( 1 ); - } - snr += (float) log10( signal / noise ); - TRANS( 1 ); - DIV( 1 ); - ADD( 1 ); - } - fac = ( (float) ( 10 * nseg ) ) / (float) n; - DIV( 1 ); - MULT( 1 ); - snr = fac * snr; - MULT( 1 ); - ADD( 1 ); - BRANCH( 1 ); - if ( snr < -99.0f ) - { - snr = -99.0f; - MOVE( 1 ); - } - return ( snr ); -} -#endif diff --git a/lib_dec/igf_dec.c b/lib_dec/igf_dec.c index 2cded75928..12c121d503 100644 --- a/lib_dec/igf_dec.c +++ b/lib_dec/igf_dec.c @@ -1590,10 +1590,19 @@ void init_igf_dec( return; } + +/*-----------------------------------------------------------------------* + * get_igf_startline() + * + * + *-----------------------------------------------------------------------*/ + +/*! r: IGF start line */ int16_t get_igf_startline( - Decoder_State *st, - int16_t L_frame, - int16_t L_frameTCX ) + Decoder_State *st, /* i : decoder state */ + const int16_t L_frame, /* i : length of the frame */ + const int16_t L_frameTCX /* i : full band frame length */ +) { int16_t igf_startline; diff --git a/lib_dec/ivas_dirac_dec_binaural_functions.c b/lib_dec/ivas_dirac_dec_binaural_functions.c index ee02a1bfe1..1cbd6cdd87 100644 --- a/lib_dec/ivas_dirac_dec_binaural_functions.c +++ b/lib_dec/ivas_dirac_dec_binaural_functions.c @@ -599,7 +599,7 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric { uint8_t ch, slot, bin, subframe; uint8_t separateCenterChannelRendering; - int16_t nBins; + int16_t nBins, idx; float frameMeanDiffusenessEneWeight[CLDFB_NO_CHANNELS_MAX]; DIRAC_DEC_HANDLE hDirAC; DIRAC_DEC_BIN_HANDLE h; @@ -609,7 +609,6 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric uint8_t applyLowBitRateEQ; int16_t dirac_read_idx; - hDirAC = st_ivas->hDirAC; h = st_ivas->hDiracDecBin; separateCenterChannelRendering = st_ivas->hOutSetup.separateChannelEnabled; @@ -850,15 +849,16 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric if ( ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) ) { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); + /* Apply the target spectrum to the eneCorrectionFactor */ if ( separateCenterChannelRendering ) /* spreadCoh mostly originates from phantom sources in separate channel rendering mode */ { - eneCorrectionFactor *= w1 * 1.0f + ( w2 + w3 ) * spreadCohEne1[min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 )]; + eneCorrectionFactor *= w1 * 1.0f + ( w2 + w3 ) * spreadCohEne1[idx]; } else { - eneCorrectionFactor *= w1 * 1.0f + w2 * spreadCohEne05[min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 )] + - w3 * spreadCohEne1[min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 )]; + eneCorrectionFactor *= w1 * 1.0f + w2 * spreadCohEne05[idx] + w3 * spreadCohEne1[idx]; } } @@ -891,8 +891,9 @@ static void ivas_dirac_dec_binaural_formulate_input_and_target_covariance_matric { if ( !h->renderStereoOutputInsteadOfBinaural ) { + idx = min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 ); /* Apply target spectrum that emphasizes low frequencies when the sound is surround coherent */ - diffEne *= ( 1.0f - surCoh ) + surCoh * surCohEne[min( bin, MASA_NUM_DEFINED_SUR_SPR_COH_ENE_BINS - 1 )]; + diffEne *= ( 1.0f - surCoh ) + surCoh * surCohEne[idx]; } } h->ChEneOut[0][bin] += diffEne; /* Diff ene part*/ diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 059ba752e7..dbaca982b7 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -3114,7 +3114,7 @@ int16_t read_surround_coherence( float error_ratio_surr; int16_t idx_ER[MASA_MAXIMUM_CODING_SUBBANDS]; int16_t bits_sur_coherence, bits_GR; - int16_t j, d, k; + int16_t j, d, k, idx; uint16_t byteBuffer; uint16_t idx_sur_coh[MASA_MAXIMUM_CODING_SUBBANDS]; IVAS_QDIRECTION *q_direction; @@ -3133,7 +3133,8 @@ int16_t read_surround_coherence( if ( hQMetaData->no_directions == 2 ) { d += hQMetaData->twoDirBands[j]; - error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[0] - q_direction[1].band_data[max( d - 1, 0 )].energy_ratio[0] * hQMetaData->twoDirBands[j]; + idx = max( d - 1, 0 ); + error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[0] - q_direction[1].band_data[idx].energy_ratio[0] * hQMetaData->twoDirBands[j]; } else { diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index ac7f942b2a..6e37511380 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -175,6 +175,7 @@ void stereo_dft_dec_sid_coh( } dtx_read_padding_bits( st, ( IVAS_SID_5k2 - 4400 ) / FRAMES_PER_SEC ); + return; } diff --git a/lib_dec/ivas_vbap.c b/lib_dec/ivas_vbap.c index f0960bd127..f0da2623aa 100644 --- a/lib_dec/ivas_vbap.c +++ b/lib_dec/ivas_vbap.c @@ -662,8 +662,7 @@ static void determine_virtual_speaker_node_division_gains( are distributed to all neighboring real speaker nodes. An amplitude-division instead of energy division is utilized just in case to avoid excessive emphasis on the coherent distributed sound. */ - int16_t c; - int16_t ch; + int16_t c, ch; float sum_val; if ( type == VIRTUAL_SPEAKER_NODE_DISTRIBUTE_ENERGY ) @@ -715,7 +714,7 @@ static void determine_virtual_speaker_node_division_gains( /*! r: virtual speaker node type */ static enum VirtualSpeakerNodeType check_need_of_virtual_speaker_node( VBAP_HANDLE hVBAPdata, /* i/o: VBAP structure */ - const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths */ + const float *speaker_node_azi_deg, /* i : vector of speaker node azimuths */ const float *speaker_node_ele_deg, /* i : vector of speaker node elevations */ enum SpeakerNodeGroup group /* i : group of speaker nodes where this belongs */ ) @@ -945,9 +944,9 @@ static void matrix_inverse_3x3( *-------------------------------------------------------------------------*/ static int16_t check_and_store_triplet( - int16_t chA, /* i : first channel index that forms the loudspeaker triplet */ - int16_t chB, /* i : second channel index that forms the loudspeaker triplet */ - int16_t chC, /* i : third channel index that forms the loudspeaker triplet */ + const int16_t chA, /* i : first channel index that forms the loudspeaker triplet */ + const int16_t chB, /* i : second channel index that forms the loudspeaker triplet */ + const int16_t chC, /* i : third channel index that forms the loudspeaker triplet */ const int16_t num_speaker_nodes, /* i : number of speaker nodes */ const VBAP_SPEAKER_NODE *speaker_node_data, /* i : speaker node data structure */ VBAP_VS_TRIPLET *triplets, /* o : vector of virtual surface triplets */ diff --git a/lib_enc/cod_tcx.c b/lib_enc/cod_tcx.c index f60ac1a314..5813ca4138 100644 --- a/lib_enc/cod_tcx.c +++ b/lib_enc/cod_tcx.c @@ -2181,9 +2181,10 @@ void coder_tcx( *-------------------------------------------------------------------*/ void coder_tcx_post( - Encoder_State *st, - float *A, - const float *Ai ) + Encoder_State *st, /* i/o: encoder memory state */ + float *A, /* o : Quantized LPC coefficients */ + const float *Ai /* i : Unquantized (interpolated) LPC coefficients */ +) { float xn_buf[L_FRAME_MAX]; diff --git a/lib_enc/enc_pit_exc.c b/lib_enc/enc_pit_exc.c index 900d4021d0..d4e20f5cc5 100644 --- a/lib_enc/enc_pit_exc.c +++ b/lib_enc/enc_pit_exc.c @@ -64,8 +64,8 @@ void enc_pit_exc( float *pitch_buf, /* i/o: Fractionnal per subframe pitch */ const int16_t nb_subfr, /* i : Number of subframe considered */ float *gpit, /* o : pitch mean gpit */ - const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ - const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ + const int16_t tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag */ + const float tdm_Pri_pitch_buf[] /* i : primary channel pitch buffer */ ) { float xn[PIT_EXC_L_SUBFR]; /* Target vector for pitch search */ diff --git a/lib_enc/ivas_agc_enc.c b/lib_enc/ivas_agc_enc.c index d8d0f1f772..9ebe2bb938 100644 --- a/lib_enc/ivas_agc_enc.c +++ b/lib_enc/ivas_agc_enc.c @@ -329,7 +329,8 @@ void ivas_agc_enc_process( { int16_t isCompensated = FALSE; actualMaxAbsVal = pState->gain_state[i].lastMaxAbs * pState->gain_state[i].lastGain; - pState->gain_state[i].gainExpVal = (int16_t) ceilf( -logf( actualMaxAbsVal * MDFT_NORM_SCALING ) / logf( pState->agc_com.winFunc[min( offset - 1, MaxAbsValIdx )] ) ); + idx = min( offset - 1, MaxAbsValIdx ); + pState->gain_state[i].gainExpVal = (int16_t) ceilf( -logf( actualMaxAbsVal * MDFT_NORM_SCALING ) / logf( pState->agc_com.winFunc[idx] ) ); while ( !isCompensated ) { diff --git a/lib_enc/ivas_core_pre_proc_front.c b/lib_enc/ivas_core_pre_proc_front.c index 1fdb26805c..9ec3362022 100644 --- a/lib_enc/ivas_core_pre_proc_front.c +++ b/lib_enc/ivas_core_pre_proc_front.c @@ -100,9 +100,8 @@ ivas_error pre_proc_front_ivas( const int16_t flag_16k_smc, /* i : flag to indicate if the OL SMC is run at 16 kHz */ const int16_t front_vad_flag, /* i : front-VAD flag to overwrite VAD decision */ const int16_t force_front_vad, /* i : flag to force VAD decision */ - const int16_t front_vad_dtx_flag /* i : front-VAD DTX flag to overwrite VAD decision*/ - , - const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ + const int16_t front_vad_dtx_flag, /* i : front-VAD DTX flag to overwrite VAD decision*/ + const int32_t ivas_total_brate /* i : IVAS total bitrate - for setting the DTX */ ) { float *inp_12k8, *new_inp_12k8; /* pointers to current frame and new data */ diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index c9f0bd70ff..7f79df3987 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -4056,27 +4056,24 @@ static int16_t encode_spread_coherence_1sf( BSTR_ENC_HANDLE hMasaMetaData /* i/o: metadata bitstream handle */ ) { - int16_t i, j; + int16_t i, j, k; int16_t idx_ER; int16_t nbits, nbits_fr; uint16_t idx_sp_coh[MASA_MAXIMUM_CODING_SUBBANDS]; uint16_t mr_idx_sp_coh[MASA_MAXIMUM_CODING_SUBBANDS]; int16_t GR_ord, bits_GR; - uint64_t idx; + uint64_t idx, idx1; int16_t no_idx16; - int16_t k; int16_t no_cv[MASA_MAXIMUM_CODING_SUBBANDS]; IVAS_QDIRECTION *q_direction; - int16_t half_coding_subbands, nbits_fr1; - uint64_t idx1; - uint8_t coding_subbands; + int16_t half_coding_subbands, nbits_fr1, coding_subbands; uint16_t idx_sp_coh_shift[MASA_MAXIMUM_CODING_SUBBANDS]; uint8_t idx_shift; int16_t max_val = 0, nbits_max; int16_t extra_cv; int16_t no_cv_shift[MASA_MAXIMUM_CODING_SUBBANDS], min_idx; - coding_subbands = (uint8_t) ( q_metadata->q_direction[idx_d].cfg.nbands ); + coding_subbands = q_metadata->q_direction[idx_d].cfg.nbands; q_direction = &( q_metadata->q_direction[idx_d] ); nbits = 0; GR_ord = 1; @@ -4237,28 +4234,25 @@ static int16_t encode_surround_coherence( BSTR_ENC_HANDLE hMetaData /* i/o: metadata bitstream handle */ ) { - int16_t i, j; - int16_t idx_ER; + int16_t i, j, k; + int16_t idx_ER, idx16; int16_t nbits, nbits_fr; uint16_t idx_sur_coh[MASA_MAXIMUM_CODING_SUBBANDS]; uint16_t mr_idx_sur_coh[MASA_MAXIMUM_CODING_SUBBANDS]; int16_t GR_ord, bits_GR; - uint64_t idx; + uint64_t idx, idx1; int16_t no_idx16; - int16_t k; int16_t no_cv[MASA_MAXIMUM_CODING_SUBBANDS]; float error_ratio_surr; IVAS_QDIRECTION *q_direction; - int16_t half_coding_subbands, nbits_fr1; - uint64_t idx1; - uint8_t coding_subbands; + int16_t half_coding_subbands, nbits_fr1, coding_subbands; int16_t all_coherence_zero; uint16_t idx_sur_coh_shift[MASA_MAXIMUM_CODING_SUBBANDS]; uint8_t idx_shift; int16_t max_val = 0, nbits_max; int16_t no_cv_shift[MASA_MAXIMUM_CODING_SUBBANDS], min_idx; - coding_subbands = (uint8_t) ( hQMetaData->q_direction[0].cfg.nbands ); + coding_subbands = hQMetaData->q_direction[0].cfg.nbands; all_coherence_zero = hQMetaData->all_coherence_zero; q_direction = &( hQMetaData->q_direction[0] ); nbits = 0; @@ -4277,7 +4271,8 @@ static int16_t encode_surround_coherence( if ( hQMetaData->no_directions == 2 ) { k += hQMetaData->twoDirBands[j]; - error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[0] - q_direction[1].band_data[max( k - 1, 0 )].energy_ratio[0] * hQMetaData->twoDirBands[j]; + idx16 = max( k - 1, 0 ); + error_ratio_surr = 1.0f - q_direction[0].band_data[j].energy_ratio[0] - q_direction[1].band_data[idx16].energy_ratio[0] * hQMetaData->twoDirBands[j]; } else { diff --git a/lib_rend/ivas_render_config.c b/lib_rend/ivas_render_config.c index 7e8caec092..73cf4d9140 100644 --- a/lib_rend/ivas_render_config.c +++ b/lib_rend/ivas_render_config.c @@ -42,6 +42,14 @@ #include "wmops.h" +/*-----------------------------------------------------------------------* + * Local constants + *-----------------------------------------------------------------------*/ + +#define IVAS_REVERB_DEFAULT_PRE_DELAY 0.016f +#define IVAS_REVERB_DEFAULT_INPUT_DELAY 0.1f + + /*-----------------------------------------------------------------------* * ivas_render_config_open() * diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 1a7cd8b830..0eefb2766f 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -89,7 +89,7 @@ ivas_error ivas_headTrack_open( void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ + float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ) { float s1, s2, s3, c1, c2, c3; @@ -158,9 +158,9 @@ void QuatToRotMat( void Quat2Euler( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ ) { if ( quat.w != -3.0 ) @@ -286,9 +286,9 @@ void rotateAziEle_DirAC( 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 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 */ + 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 */ ) { int16_t i, l, n, m; @@ -341,9 +341,9 @@ void rotateFrame_shd( for ( m = m1; m < m2; m++ ) { /* crossfade with previous rotation gains */ - tmpRot[n - m1] += cross_fade[i] * SHrotmat[n][m] * output[m][subframe_idx * subframe_len + i] + ( 1 - cross_fade[i] ) * SHrotmat_prev[n][m] * output[m][subframe_idx * subframe_len + i]; - } - } + tmpRot[n - m1] += cross_fade[i] * SHrotmat[n][m] * output[m][subframe_idx * subframe_len + i] + ( 1 - cross_fade[i] ) * SHrotmat_prev[n][m] * output[m][subframe_idx * subframe_len + i]; + } + } /* write back the result */ for ( n = m1; n < m2; n++ ) { @@ -389,10 +389,10 @@ 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 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 */ - const int16_t subframe_idx /* i : subframe index */ + 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 */ + const int16_t subframe_idx /* i : subframe index */ ) { int16_t i, j; @@ -494,8 +494,8 @@ void rotateFrame_sd( { output_tmp[ch_out][i] += ( cross_fade[j] ) * gains[ch_in][ch_out] * output[ch_in][i] + ( 1 - cross_fade[j] ) * gains_prev[ch_in][ch_out] * output[ch_in][i]; } + } } - } /* move Rmat to Rmat_prev */ for ( i = 0; i < 3; i++ ) @@ -785,14 +785,13 @@ static float SHrot_v( float R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] ) { - float d = 0.0f; - float p0 = 0.0f, p1 = 0.0f; + float result, d, p0, p1; if ( m == 0 ) { p0 = SHrot_p( 1, l, 1, n, SHrotmat, R_lm1 ); p1 = SHrot_p( -1, l, -1, n, SHrotmat, R_lm1 ); - return p0 + p1; + result = p0 + p1; } else { @@ -801,16 +800,18 @@ static float SHrot_v( d = ( m == 1 ) ? 1.0f : 0.0f; p0 = SHrot_p( 1, l, m - 1, n, SHrotmat, R_lm1 ); p1 = SHrot_p( -1, l, -m + 1, n, SHrotmat, R_lm1 ); - return p0 * sqrtf( 1.0f + d ) - p1 * ( 1.0f - d ); + result = p0 * sqrtf( 1.0f + d ) - p1 * ( 1.0f - d ); } else { d = ( m == -1 ) ? 1.0f : 0.0f; p0 = SHrot_p( 1, l, m + 1, n, SHrotmat, R_lm1 ); p1 = SHrot_p( -1, l, -m - 1, n, SHrotmat, R_lm1 ); - return p0 * ( 1.0f - d ) + p1 * sqrtf( 1.0f + d ); + result = p0 * ( 1.0f - d ) + p1 * sqrtf( 1.0f + d ); } } + + return result; } static float SHrot_w( @@ -820,13 +821,12 @@ static float SHrot_w( float SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], float R_lm1[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM] ) { - float p0 = 0.0f; - float p1 = 0.0f; + float result, p0, p1; if ( m == 0 ) { printf( "ERROR should not be called\n" ); - return 0.0; + return 0.0f; } else { @@ -834,17 +834,26 @@ static float SHrot_w( { p0 = SHrot_p( 1, l, m + 1, n, SHrotmat, R_lm1 ); p1 = SHrot_p( -1, l, -m - 1, n, SHrotmat, R_lm1 ); - return p0 + p1; + result = p0 + p1; } else { p0 = SHrot_p( 1, l, m - 1, n, SHrotmat, R_lm1 ); p1 = SHrot_p( -1, l, -m + 1, n, SHrotmat, R_lm1 ); - return p0 - p1; + result = p0 - p1; } } + + return result; } + +/*------------------------------------------------------------------------- + * rotateFrame_sd_cldfb() + * + * + *------------------------------------------------------------------------*/ + void SHrotmatgen( float SHrotmat[HEADROT_SHMAT_DIM][HEADROT_SHMAT_DIM], /* o : rotation matrix in SHD */ float Rmat[3][3], /* i : real-space rotation matrix */ diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index f682a0731f..d9741fe694 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -462,9 +462,9 @@ AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( return AUDIO_CONFIG_HOA2; case IVAS_REND_AUDIO_CONFIG_HOA3: return AUDIO_CONFIG_HOA3; - default: - return AUDIO_CONFIG_INVALID; } + + return AUDIO_CONFIG_INVALID; } static ivas_error initLimiter( -- GitLab From 687394391ce0f0068a63060cc55c3f3cbfea96a5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Dec 2022 18:57:00 +0100 Subject: [PATCH 2/7] formatting --- lib_com/ivas_prot.h | 9 +++------ lib_com/prot.h | 5 ++--- lib_dec/ivas_stereo_dft_dec.c | 7 +++---- lib_enc/ivas_mct_core_enc.c | 14 ++++++-------- lib_enc/ivas_stereo_cng_enc.c | 5 ++--- lib_enc/vad.c | 17 ++++++++--------- 6 files changed, 24 insertions(+), 33 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 2c265afda1..abc8569d95 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1147,8 +1147,7 @@ void stereo_dft_dec_read_BS( void stereo_dft_dec_smooth_parameters( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */ - , + const int16_t prev_sid_nodata, /* i : Previous SID/No data indicator */ const int16_t active_frame_counter, /* i : Active frame counter */ const int32_t element_brate /* i : Element bitrate */ ); @@ -2423,8 +2422,7 @@ void stereo_cng_upd_counters( const int32_t element_mode, /* i : element mode */ const int16_t nbands, /* i : Number of bands in active */ const float sidSideGain[], /* i : SID side gains */ - const int16_t burst_ho_count /* i : Hang-over count */ - , + const int16_t burst_ho_count, /* i : Hang-over count */ int16_t *coh_fade_counter /* i : Coherence fade counter */ ); @@ -2656,8 +2654,7 @@ void ivas_mct_core_enc( const int16_t nChannels, /* i : number of channels to be coded */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t switch_bw, /* i : flag bandwidth switch occurance */ - const int16_t lfe_bits /* i : bits spent for LFE */ - , + const int16_t lfe_bits, /* i : bits spent for LFE */ const int16_t sba_order /* i : Ambisonic (SBA) order */ ); diff --git a/lib_com/prot.h b/lib_com/prot.h index 03e3ccb8ce..5878ef7f50 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -3832,9 +3832,8 @@ int16_t dtx_hangover_addition( const int16_t cldfb_subtraction, /* i : */ int16_t *vad_hover_flag, /* o : VAD hangover flag */ VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */ - NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ - , - int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ + NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ + int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ ); int16_t wb_vad( diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index fbe01d1571..cf7783929c 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -2760,10 +2760,9 @@ void stereo_dft_generate_res_pred( void stereo_dft_dec_smooth_parameters( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t prev_sid_nodata /* i : Previous SID/No data indicator */ - , - const int16_t active_frame_counter, /* i : Active frame counter */ - const int32_t element_brate /* i : Element bitrate */ + const int16_t prev_sid_nodata, /* i : Previous SID/No data indicator */ + const int16_t active_frame_counter, /* i : Active frame counter */ + const int32_t element_brate /* i : Element bitrate */ ) { int16_t k_offset, k, k2, b, N_div; diff --git a/lib_enc/ivas_mct_core_enc.c b/lib_enc/ivas_mct_core_enc.c index 379a1c8358..614059aa27 100644 --- a/lib_enc/ivas_mct_core_enc.c +++ b/lib_enc/ivas_mct_core_enc.c @@ -114,11 +114,10 @@ static void FindChannelRatio( static void AdjustChannelRatios( int16_t chBitRatios[MCT_MAX_CHANNELS], /* o : bit-disctribution channel ratios */ - const int16_t nChannels /* i/o: number of channels */ - , - const int32_t ivas_total_brate, /* i : IVAS total bitrate */ - const int16_t nAvailBits, /* i : number of available bits */ - const int16_t sba_order /* i : Ambisonic (SBA) order */ + const int16_t nChannels, /* i/o: number of channels */ + const int32_t ivas_total_brate, /* i : IVAS total bitrate */ + const int16_t nAvailBits, /* i : number of available bits */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ) { int16_t force_ch_bit_ratios[IVAS_SPAR_MAX_DMX_CHS]; @@ -196,9 +195,8 @@ void ivas_mct_core_enc( const int16_t nChannels, /* i : number of channels to be coded */ const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t switch_bw, /* i : flag bandwidth switch occurance */ - const int16_t lfe_bits /* i : bits spent for LFE */ - , - const int16_t sba_order /* i : Ambisonic (SBA) order */ + const int16_t lfe_bits, /* i : bits spent for LFE */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ) { int16_t ch, ch_core, nSubframes, L_subframeTCX; diff --git a/lib_enc/ivas_stereo_cng_enc.c b/lib_enc/ivas_stereo_cng_enc.c index ca15794cc0..ea75419724 100644 --- a/lib_enc/ivas_stereo_cng_enc.c +++ b/lib_enc/ivas_stereo_cng_enc.c @@ -491,9 +491,8 @@ void stereo_cng_upd_counters( const int32_t element_mode, /* i : element mode */ const int16_t nbands, /* i : Number of bands in active */ const float sidSideGain[], /* i : SID side gains */ - const int16_t burst_ho_count /* i : Hang-over count */ - , - int16_t *coh_fade_counter /* i : Coherence fade counter */ + const int16_t burst_ho_count, /* i : Hang-over count */ + int16_t *coh_fade_counter /* i : Coherence fade counter */ ) { int16_t b; diff --git a/lib_enc/vad.c b/lib_enc/vad.c index 5379f86dc0..1812085689 100644 --- a/lib_enc/vad.c +++ b/lib_enc/vad.c @@ -155,15 +155,14 @@ static void sign_thr_snr_acc( *-----------------------------------------------------------------*/ int16_t dtx_hangover_addition( - Encoder_State *st, /* i/o: encoder state structure */ - const int16_t vad_flag, /* i : VAD flag */ - const float lp_snr, /* i : input single SNR estimate */ - const int16_t cldfb_subtraction, /* i : */ - int16_t *vad_hover_flag, /* o : VAD hangover flag */ - VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */ - NOISE_EST_HANDLE hNoiseEst /* i : Noise estimation handle */ - , - int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ + Encoder_State *st, /* i/o: encoder state structure */ + const int16_t vad_flag, /* i : VAD flag */ + const float lp_snr, /* i : input single SNR estimate */ + const int16_t cldfb_subtraction, /* i : */ + int16_t *vad_hover_flag, /* o : VAD hangover flag */ + VAD_HANDLE hVAD, /* i/o: VAD handle for L or R channel */ + NOISE_EST_HANDLE hNoiseEst, /* i : Noise estimation handle */ + int16_t *rem_dtx_ho /* o : Expected remaining hangover frames */ ) { int16_t hangover_short_dtx, flag_dtx; -- GitLab From 99b3c8190e82558d9269edfdd9b69b3999ae1a4a Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Dec 2022 18:57:19 +0100 Subject: [PATCH 3/7] correct typo --- lib_enc/nois_est.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_enc/nois_est.c b/lib_enc/nois_est.c index b8d551a738..ad07d46945 100644 --- a/lib_enc/nois_est.c +++ b/lib_enc/nois_est.c @@ -232,7 +232,7 @@ void noise_est_pre( /*-----------------------------------------------------------------* * noise_est_down() * - * Down-ward noise udatation routine + * Down-ward noise updatation routine * Total Noise computation, relative frame Energy computation * Noise energy update - here, the energy is updated only if it is * decreasing to improve noise suppression. Otherwise, the noise -- GitLab From 9789007ed9a2afbf0b61eda72357111acc154056 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Dec 2022 19:02:57 +0100 Subject: [PATCH 4/7] cleaning" remove one level of dereferencing of st_ivas->hDecoderConfig/st_ivas->hEncoderConfig --- lib_dec/ivas_sba_dec.c | 20 ++++++++++---------- lib_enc/ivas_sba_enc.c | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 4e96c041bd..077cf97c02 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -70,8 +70,8 @@ ivas_error ivas_sba_dec_reinit( error = IVAS_ERR_OK; - output_Fs = st_ivas->hDecoderConfig->output_Fs; hDecoderConfig = st_ivas->hDecoderConfig; + output_Fs = hDecoderConfig->output_Fs; output_config = hDecoderConfig->output_config; ivas_total_brate = hDecoderConfig->ivas_total_brate; @@ -90,7 +90,7 @@ ivas_error ivas_sba_dec_reinit( { if ( st_ivas->ivas_format == ISM_FORMAT ) { - ivas_param_ism_dec_close( st_ivas->hDirAC, st_ivas->hDecoderConfig->output_config ); + ivas_param_ism_dec_close( st_ivas->hDirAC, hDecoderConfig->output_config ); } else { @@ -102,7 +102,7 @@ ivas_error ivas_sba_dec_reinit( /* Spar handle */ if ( st_ivas->hSpar != NULL ) { - ivas_spar_dec_close( st_ivas->hSpar, st_ivas->hDecoderConfig->output_Fs ); + ivas_spar_dec_close( st_ivas->hSpar, hDecoderConfig->output_Fs ); st_ivas->hSpar = NULL; } @@ -247,7 +247,7 @@ ivas_error ivas_sba_dec_reinit( *------------------------------------------------------------------------------------------*/ /* Allocate and initialize Custom loudspeaker layout handle */ - if ( st_ivas->hDecoderConfig->Opt_LsCustom ) + if ( hDecoderConfig->Opt_LsCustom ) { if ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) { @@ -256,7 +256,7 @@ ivas_error ivas_sba_dec_reinit( } /* Allocate and initialize Head-Tracking handle */ - if ( st_ivas->hDecoderConfig->Opt_Headrotation ) + if ( hDecoderConfig->Opt_Headrotation ) { if ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) { @@ -265,7 +265,7 @@ ivas_error ivas_sba_dec_reinit( } /* Allocate HRTF binary handle */ - if ( st_ivas->hDecoderConfig->Opt_HRTF_binary ) + if ( hDecoderConfig->Opt_HRTF_binary ) { if ( ( error = ivas_HRTF_binary_open( &( st_ivas->hHrtfTD ) ) ) != IVAS_ERR_OK ) { @@ -321,7 +321,7 @@ ivas_error ivas_sba_dec_reinit( st_ivas->hSpar->enc_param_start_band = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( st_ivas->hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), + ivas_dirac_config_bands( band_grouping, IVAS_MAX_NUM_BANDS, (int16_t) ( hDecoderConfig->output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ), st_ivas->hSpar->dirac_to_spar_md_bands, st_ivas->hQMetaData->useLowerBandRes, st_ivas->hSpar->enc_param_start_band, 0 ); } } @@ -449,13 +449,13 @@ ivas_error ivas_sba_dec_reinit( set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM ); } - if ( st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) + if ( hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL || hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) { if ( ( error = ivas_render_config_open( &( st_ivas->hRenderConfig ) ) ) != IVAS_ERR_OK ) { return error; } - if ( ivas_render_config_init_from_rom( &st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) != IVAS_ERR_OK ) + if ( ivas_render_config_init_from_rom( &st_ivas->hRenderConfig, hDecoderConfig->output_config == AUDIO_CONFIG_BINAURAL_ROOM ) != IVAS_ERR_OK ) { return IVAS_ERR_INTERNAL_FATAL; } @@ -629,7 +629,7 @@ ivas_error ivas_sba_dec_reconfigure( /* PCA handle */ if ( hSpar != NULL ) { - if ( st_ivas->hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) + if ( hDecoderConfig->ivas_total_brate == PCA_BRATE && sba_order_internal == 1 ) { if ( ( hSpar->hPCA = (PCA_DEC_STATE *) count_malloc( sizeof( PCA_DEC_STATE ) ) ) == NULL ) { diff --git a/lib_enc/ivas_sba_enc.c b/lib_enc/ivas_sba_enc.c index 04aba97747..8c5029fc4d 100644 --- a/lib_enc/ivas_sba_enc.c +++ b/lib_enc/ivas_sba_enc.c @@ -328,15 +328,14 @@ ivas_error ivas_sba_enc_reconfigure( int16_t nSCE_old, nCPE_old, nchan_transport_old; int32_t ivas_total_brate; ivas_error error; + ENCODER_CONFIG_HANDLE hEncoderConfig; error = IVAS_ERR_OK; - ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate; -#ifdef SBA_BR_SWITCHING_2 - ENCODER_CONFIG_HANDLE hEncoderConfig; hEncoderConfig = st_ivas->hEncoderConfig; -#endif - if ( ivas_total_brate != st_ivas->hEncoderConfig->last_ivas_total_brate ) + ivas_total_brate = hEncoderConfig->ivas_total_brate; + + if ( ivas_total_brate != hEncoderConfig->last_ivas_total_brate ) { #ifdef SBA_BR_SWITCHING_2 DIRAC_ENC_HANDLE hDirAC = st_ivas->hDirAC; @@ -346,7 +345,8 @@ ivas_error ivas_sba_enc_reconfigure( nCPE_old = st_ivas->nCPE; nSCE_old = st_ivas->nSCE; - st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, st_ivas->hEncoderConfig->sba_order ); + st_ivas->sba_analysis_order = ivas_sba_get_analysis_order( ivas_total_brate, hEncoderConfig->sba_order ); + #ifdef SBA_BR_SWITCHING_2 st_ivas->sba_mode = ivas_sba_mode_select( ivas_total_brate ); -- GitLab From 8963d7eb1d38c15b0ee75afb1345f939e45b60a3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Dec 2022 19:09:52 +0100 Subject: [PATCH 5/7] fix Linux build warning --- lib_rend/lib_rend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index d9741fe694..e62cf8c845 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -462,6 +462,8 @@ AUDIO_CONFIG getIvasAudioConfigFromRendAudioConfig( return AUDIO_CONFIG_HOA2; case IVAS_REND_AUDIO_CONFIG_HOA3: return AUDIO_CONFIG_HOA3; + default: + break; } return AUDIO_CONFIG_INVALID; -- GitLab From 73345a9f23e5c64cc87efd60ad48229ceca4c1bc Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 15 Dec 2022 19:15:07 +0100 Subject: [PATCH 6/7] apply clang-format --- lib_rend/ivas_rotation.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 0eefb2766f..60cbb5e9b8 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -89,7 +89,7 @@ ivas_error ivas_headTrack_open( void QuatToRotMat( const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ + float Rmat[3][3] /* o : real-space rotation matrix for this rotation */ ) { float s1, s2, s3, c1, c2, c3; @@ -157,10 +157,10 @@ void QuatToRotMat( *------------------------------------------------------------------------*/ void Quat2Euler( - const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ - float *yaw, /* o : yaw */ - float *pitch, /* o : pitch */ - float *roll /* o : roll */ + const IVAS_QUATERNION quat, /* i : quaternion describing the rotation */ + float *yaw, /* o : yaw */ + float *pitch, /* o : pitch */ + float *roll /* o : roll */ ) { if ( quat.w != -3.0 ) @@ -286,9 +286,9 @@ void rotateAziEle_DirAC( 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 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 */ + 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 */ ) { int16_t i, l, n, m; @@ -341,9 +341,9 @@ void rotateFrame_shd( for ( m = m1; m < m2; m++ ) { /* crossfade with previous rotation gains */ - tmpRot[n - m1] += cross_fade[i] * SHrotmat[n][m] * output[m][subframe_idx * subframe_len + i] + ( 1 - cross_fade[i] ) * SHrotmat_prev[n][m] * output[m][subframe_idx * subframe_len + i]; - } - } + tmpRot[n - m1] += cross_fade[i] * SHrotmat[n][m] * output[m][subframe_idx * subframe_len + i] + ( 1 - cross_fade[i] ) * SHrotmat_prev[n][m] * output[m][subframe_idx * subframe_len + i]; + } + } /* write back the result */ for ( n = m1; n < m2; n++ ) { @@ -389,10 +389,10 @@ 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 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 */ - const int16_t subframe_idx /* i : subframe index */ + 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 */ + const int16_t subframe_idx /* i : subframe index */ ) { int16_t i, j; @@ -494,8 +494,8 @@ void rotateFrame_sd( { output_tmp[ch_out][i] += ( cross_fade[j] ) * gains[ch_in][ch_out] * output[ch_in][i] + ( 1 - cross_fade[j] ) * gains_prev[ch_in][ch_out] * output[ch_in][i]; } - } } + } /* move Rmat to Rmat_prev */ for ( i = 0; i < 3; i++ ) @@ -851,7 +851,7 @@ static float SHrot_w( /*------------------------------------------------------------------------- * rotateFrame_sd_cldfb() * - * + * *------------------------------------------------------------------------*/ void SHrotmatgen( -- GitLab From b4e389b3c3fbaa7e7f70059fa374614bce6f5395 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 16 Dec 2022 00:21:53 +0100 Subject: [PATCH 7/7] remove useless brackets --- lib_com/delay_comp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index 4bcac1555e..30448082b5 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -101,9 +101,7 @@ int32_t get_delay( } /* compensate for Binaural renderer HRTF delay */ - { - delay += binaural_latency_ns; - } + delay += binaural_latency_ns; } } -- GitLab