From c8247e595b8453f059bd5fc6171253257443fd5e Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 31 Aug 2022 15:36:05 +0200 Subject: [PATCH 01/10] editorial improvements --- lib_com/ivas_prot.h | 11 +++++------ lib_com/ivas_rom_com.c | 16 +++++++++++----- lib_com/prot.h | 12 +++++------- lib_dec/core_dec_switch.c | 2 +- lib_dec/er_dec_tcx.c | 5 ++--- lib_dec/swb_tbe_dec.c | 9 ++++----- lib_enc/ivas_stereo_switching_enc.c | 15 +++++++-------- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c44bd4b975..c2a9b67a44 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -794,8 +794,8 @@ void ivas_param_ism_enc( ); void ivas_param_ism_enc_close( - DIRAC_ENC_HANDLE hDirAC /* i/o: encoder DirAC handle */ - ,const int32_t input_Fs /* i : input sampling_rate */ + DIRAC_ENC_HANDLE hDirAC, /* i/o: encoder DirAC handle */ + const int32_t input_Fs /* i : input sampling_rate */ ); void ivas_param_ism_stereo_dmx( @@ -2508,8 +2508,7 @@ ivas_error stereo_memory_enc( const int32_t input_Fs, /* i : input sampling rate */ const int16_t max_bwidth, /* i : maximum audio bandwidth */ float *tdm_last_ratio, /* o : TD stereo last ratio */ - const IVAS_FORMAT ivas_format /* i : IVAS format */ - , + const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int16_t nchan_transport /* i : number transport chans */ ); @@ -3355,8 +3354,8 @@ void ivas_dirac_dec_output_synthesis_process_subframe_psd_ls( float RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ float ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX],/* i : LS signals */ DIRAC_DEC_HANDLE hDirAC, /* i/o: DirAC handle */ - float *reference_power_smooth - , float qualityBasedSmFactor + float *reference_power_smooth, + float qualityBasedSmFactor ); void ivas_dirac_dec_get_response( diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index e2ba9b8233..6e101da897 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3363,7 +3363,8 @@ const float ivas_mdft_coeff_cos_twid_960[IVAS_960_PT_LEN + 1] = 0.00654493796735196f, 0.00490871880799808f, 0.00327248650652671f, 0.00163624544362412f, 0.00000000000000000f }; -const float ivas_mdft_coeff_cos_twid_640[IVAS_640_PT_LEN +1] = + +const float ivas_mdft_coeff_cos_twid_640[IVAS_640_PT_LEN + 1] = { 1.00000000000000f, 0.999996988037278f, 0.999987952167257f, 0.999972892444367f, 0.999951808959328f, 0.999924701839145f, 0.999891571247108f, 0.999852417382795f, @@ -3524,9 +3525,10 @@ const float ivas_mdft_coeff_cos_twid_640[IVAS_640_PT_LEN +1] = 0.0392598157590687f, 0.0368072229413588f, 0.0343544083996823f, 0.0319013869096110f, 0.0294481732479634f, 0.0269947821927155f, 0.0245412285229123f, 0.0220875270185784f, 0.0196336924606283f, 0.0171797396307788f, 0.0147256833114584f, 0.0122715382857199f, - 0.00981731933714973f, 0.00736304124977978f, 0.00490871880799808f, 0.00245436679646048f - ,0.00000000000000000f + 0.00981731933714973f, 0.00736304124977978f, 0.00490871880799808f, 0.00245436679646048f, + 0.00000000000000000f }; + const float ivas_mdft_coeff_cos_twid_320[IVAS_320_PT_LEN + 1] = { 1.00000000000000f, 0.999987952167257f, 0.999951808959328f, 0.999891571247108f, @@ -3608,9 +3610,10 @@ const float ivas_mdft_coeff_cos_twid_320[IVAS_320_PT_LEN + 1] = 0.0784590957278450f, 0.0735645635996675f, 0.0686682588843738f, 0.0637702995616845f, 0.0588708036511890f, 0.0539698892095020f, 0.0490676743274181f, 0.0441642771270675f, 0.0392598157590687f, 0.0343544083996823f, 0.0294481732479634f, 0.0245412285229123f, - 0.0196336924606283f, 0.0147256833114584f, 0.00981731933714973f, 0.00490871880799808f - ,0.0000000000000000f + 0.0196336924606283f, 0.0147256833114584f, 0.00981731933714973f, 0.00490871880799808f, + 0.0000000000000000f }; + const float ivas_mdft_coeff_cos_twid_240[IVAS_240_PT_LEN + 1] = { 1.0000000000f, 0.9999785817f, 0.9999143276f, 0.9998072405f, 0.9996573250f, 0.9994645875f, @@ -3685,6 +3688,7 @@ const float ivas_mdft_coeff_cos_twid_160[IVAS_160_PT_LEN + 1] = 0.0980171403f, 0.0882423705f, 0.0784590957f, 0.0686682589f, 0.0588708037f, 0.0490676743f, 0.0392598158f, 0.0294481732f, 0.0196336925f, 0.0098173193f, 0.000000000f }; + const float ivas_mdft_coeff_cos_twid_80[IVAS_80_PT_LEN + 1] = { 1.0000000000f, 0.9998072405f, 0.9992290362f, 0.9982656102f, 0.9969173337f, 0.9951847267f, @@ -3702,6 +3706,7 @@ const float ivas_mdft_coeff_cos_twid_80[IVAS_80_PT_LEN + 1] = 0.1564344650f, 0.1370123417f, 0.1175373975f, 0.0980171403f, 0.0784590957f, 0.0588708037f, 0.0392598158f, 0.0196336925f, 0.000000000f }; + const float ivas_mdft_coeff_cos_twid_40[IVAS_40_PT_LEN + 1] = { 1.0000000000f, 0.9992290362f, 0.9969173337f, 0.9930684570f, 0.9876883406f, 0.9807852804f, @@ -3712,6 +3717,7 @@ const float ivas_mdft_coeff_cos_twid_40[IVAS_40_PT_LEN + 1] = 0.3826834324f, 0.3461170571f, 0.3090169944f, 0.2714404499f, 0.2334453639f, 0.1950903220f, 0.1564344650f, 0.1175373975f, 0.0784590957f, 0.0392598158f, 0.000000000f }; + const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1] = { -0.000818122995607253f, -0.00736304124977957f, -0.0139076440957708f, -0.0204516511845773f, diff --git a/lib_com/prot.h b/lib_com/prot.h index d9b238bdf0..d9a80e70e6 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2773,13 +2773,11 @@ void fb_tbe_enc( ); void fb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const float fb_exc[], /* i : FB excitation from the SWB part */ - float *hb_synth, /* i/o: high-band synthesis */ - float *fb_synth_ref /* o : high-band synthesis 16-20 kHz */ - , + Decoder_State *st, /* i/o: decoder state structure */ + const float fb_exc[], /* i : FB excitation from the SWB part */ + float *hb_synth, /* i/o: high-band synthesis */ + float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */ const int16_t output_frame /* i: output frame length */ - ); void calc_tilt_bwe( @@ -9249,7 +9247,7 @@ void mode_switch_decoder_LPD( const int16_t is_mct /* i : MCT mode flag */ #ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT , - const int16_t last_element_mode + const int16_t last_element_mode /* i : last element mode */ #endif ); diff --git a/lib_dec/core_dec_switch.c b/lib_dec/core_dec_switch.c index 637c185f32..f952a8638f 100644 --- a/lib_dec/core_dec_switch.c +++ b/lib_dec/core_dec_switch.c @@ -59,7 +59,7 @@ void mode_switch_decoder_LPD( const int16_t is_mct /* i : MCT mode flag */ #ifdef FIX_IVAS_185_MDCT_ST_PLC_FADEOUT , - const int16_t last_element_mode + const int16_t last_element_mode /* i : last element mode */ #endif ) { diff --git a/lib_dec/er_dec_tcx.c b/lib_dec/er_dec_tcx.c index 2fb4a8979a..18a71c9939 100644 --- a/lib_dec/er_dec_tcx.c +++ b/lib_dec/er_dec_tcx.c @@ -52,9 +52,8 @@ *-----------------------------------------------------------------*/ void con_tcx( - Decoder_State *st, /* i/o: coder memory state */ - float synth[] /* i/o: synth[] */ - , + Decoder_State *st, /* i/o: coder memory state */ + float synth[], /* i/o: synth[] */ const float coh, /* i : coherence of stereo signal */ int16_t *noise_seed, /* i/o: noise seed for stereo */ const int16_t only_left /* i : TD-PLC only in left channel */ diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 03d9162e34..806cc27041 100755 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1973,11 +1973,10 @@ static void dequantizeSHBparams( *-------------------------------------------------------------------*/ void fb_tbe_dec( - Decoder_State *st, /* i/o: decoder state structure */ - const float fb_exc[], /* i : FB excitation from the SWB part */ - float *hb_synth, /* o : high-band synthesis */ - float *fb_synth_ref /* o : high-band synthesis 16-20 kHz */ - , + Decoder_State *st, /* i/o: decoder state structure */ + const float fb_exc[], /* i : FB excitation from the SWB part */ + float *hb_synth, /* o : high-band synthesis */ + float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */ const int16_t output_frame /* i: output frame length */ ) { diff --git a/lib_enc/ivas_stereo_switching_enc.c b/lib_enc/ivas_stereo_switching_enc.c index 9075d73595..d0201784a6 100644 --- a/lib_enc/ivas_stereo_switching_enc.c +++ b/lib_enc/ivas_stereo_switching_enc.c @@ -218,13 +218,12 @@ static void deallocate_CoreCoder_enc( *-------------------------------------------------------------------*/ ivas_error stereo_memory_enc( - CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ - const int32_t input_Fs, /* i : input sampling rate */ - const int16_t max_bwidth, /* i : maximum audio bandwidth */ - float *tdm_last_ratio, /* o : TD stereo last ratio */ - const IVAS_FORMAT ivas_format /* i : ivas format */ - , - const int16_t nchan_transport /* i : number transport chans */ + CPE_ENC_HANDLE hCPE, /* i : CPE encoder structure */ + const int32_t input_Fs, /* i : input sampling rate */ + const int16_t max_bwidth, /* i : maximum audio bandwidth */ + float *tdm_last_ratio, /* o : TD stereo last ratio */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const int16_t nchan_transport /* i : number transport chans */ ) { Encoder_State *st; @@ -538,7 +537,7 @@ ivas_error stereo_memory_enc( #endif initMdctStereoEncData( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, hCPE->hCoreCoder[0]->max_bwidth, 0, NULL, 1 ); - hCPE->hStereoMdct->isSBAStereoMode = ( ( ivas_format == SBA_FORMAT ) && ( nchan_transport == 2 ) ); + hCPE->hStereoMdct->isSBAStereoMode = ( ivas_format == SBA_FORMAT && nchan_transport == 2 ); if ( hCPE->element_mode == IVAS_CPE_MDCT && hCPE->element_brate <= MAX_MDCT_ITD_BRATE && ivas_format == STEREO_FORMAT ) { -- GitLab From 0c6d10b0ab632c9483524e2573bcb3bc66c03679 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 1 Sep 2022 07:55:49 +0200 Subject: [PATCH 02/10] address comment related to issue 58 --- lib_dec/ivas_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index a103c9f45f..c176a2b225 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -571,7 +571,7 @@ ivas_error ivas_dec( st_ivas->ini_frame++; } - if ( st_ivas->ini_active_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && ivas_total_brate > IVAS_SID_4k4 ) // VE: looks strange: ini_frame -> ini_frame_active ? + if ( st_ivas->ini_active_frame < MAX_FRAME_COUNTER && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && ivas_total_brate > IVAS_SID_4k4 ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ { st_ivas->ini_active_frame++; } -- GitLab From d99829ccae492895b03d1eb7ac603f2a94e3ec5f Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 1 Sep 2022 12:18:27 +0200 Subject: [PATCH 03/10] remove "TD Renderer result code." description as it is actually ivas_error; simplify returns for TD renderer functions --- lib_com/ivas_prot.h | 25 +++++-------------------- lib_dec/ivas_hrtf.c | 4 ++-- lib_dec/ivas_objectRenderer.c | 22 ++++++++++++---------- lib_dec/ivas_objectRenderer_hrFilt.c | 9 +++------ lib_dec/ivas_objectRenderer_mix.c | 9 ++------- lib_dec/ivas_objectRenderer_sfx.c | 25 ++++++++++++------------- lib_dec/ivas_objectRenderer_sources.c | 12 +++--------- lib_util/hrtf_file_reader.c | 3 ++- 8 files changed, 41 insertions(+), 68 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c2a9b67a44..ad980d2665 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4871,8 +4871,7 @@ void ivas_HRTF_binary_close( TDREND_HRFILT_FiltSet_t **hHrtfTD /* i/o: TD renderer HRTF handle */ ); -/*! r: TD Renderer result code. */ -ivas_error DefaultBSplineModel( +void DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ const int32_t output_Fs /* i : Output sampling rate */ ); @@ -4885,7 +4884,7 @@ void ivas_td_binaural_close( BINAURAL_TD_OBJECT_RENDERER_HANDLE *hBinRendererTd /* i/o: TD binaural object renderer handle */ ); -ivas_error ObjRenderIVASFrame( +void ObjRenderIVASFrame( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame /* i : output frame length */ @@ -4937,35 +4936,30 @@ ivas_error TDREND_REND_RenderSourceHRFilt( /* ----- Object renderer - sources ----- */ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetPos( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const float *Vec_p /* i : Position vector */ ); -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetDir( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const float *Vec_p /* i : Direction vector */ ); -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetDirAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ); -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetPlayState( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const TDREND_PlayStatus_t PlayStatus /* i : Play state */ ); - void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_SRC_REND_t *SrcRend_p, /* i/o: Source object */ @@ -4973,7 +4967,6 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( const int32_t output_Fs /* i : Output sample rate */ ); -/*! r: TD Renderer result code. */ ivas_error TDREND_SRC_Alloc( TDREND_SRC_t **Src_pp /* i/o: Source */ ); @@ -5027,7 +5020,6 @@ int16_t TDREND_SPATIAL_EvalOrthonormOrient( /* ----- Object renderer - mix ----- */ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_AddSrc( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ int16_t *SrcInd, /* o : Source index */ @@ -5035,19 +5027,16 @@ ivas_error TDREND_MIX_AddSrc( const int32_t output_Fs /* i : Output sampling rate */ ); -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SetDistAttenModel( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const TDREND_DistAttenModel_t DistAttenModel /* i : Distance attenuation model */ ); -/*! r: TD Renderer result code. */ -ivas_error TDREND_MIX_LIST_SetPos( +void TDREND_MIX_LIST_SetPos( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const float *Pos_p /* i : Listener's position */ ); -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_LIST_SetOrient( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const float *FrontVec_p, /* i : Listener's orientation front vector */ @@ -5058,7 +5047,6 @@ void TDREND_MIX_Dealloc( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd /* i/o: TD renderer handle */ ); -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_Init( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ @@ -5068,21 +5056,18 @@ ivas_error TDREND_MIX_Init( /* ----- Object renderer - sfx ----- */ -/*! r: TD Renderer result code. */ ivas_error TDREND_SFX_SpatBin_Initialize( SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters handle */ const int32_t output_Fs /* i : Output sampling rate */ ); -/*! r: TD Renderer result code. */ -ivas_error TDREND_SFX_SpatBin_SetParams( +void TDREND_SFX_SpatBin_SetParams( SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct to be updated */ const SFX_SpatBin_Params_t *NewParam_p, /* i : New parameters struct */ const int32_t output_Fs /* i : Output sample rate */ ); -/*! r: TD Renderer result code. */ -ivas_error TDREND_SFX_SpatBin_Execute_Main( +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 */ diff --git a/lib_dec/ivas_hrtf.c b/lib_dec/ivas_hrtf.c index eebe3b037f..2169267206 100644 --- a/lib_dec/ivas_hrtf.c +++ b/lib_dec/ivas_hrtf.c @@ -75,7 +75,7 @@ void BSplineModelEvalAlloc( * Init default HRTF model --------------------------------------------------------------------*/ -ivas_error DefaultBSplineModel( +void DefaultBSplineModel( TDREND_HRFILT_FiltSet_t *HrFiltSet_p, /* o : Loaded HR filter set */ const int32_t output_Fs /* i : Output sampling rate */ ) @@ -216,7 +216,7 @@ ivas_error DefaultBSplineModel( HrFiltSet_p->FiltLength = HrFiltSet_p->ModelParams.K; BSplineModelEvalAlloc( &HrFiltSet_p->ModelParams, &HrFiltSet_p->ModelEval ); - return IVAS_ERR_OK; + return; } diff --git a/lib_dec/ivas_objectRenderer.c b/lib_dec/ivas_objectRenderer.c index c461650d6b..fe33031ad6 100644 --- a/lib_dec/ivas_objectRenderer.c +++ b/lib_dec/ivas_objectRenderer.c @@ -45,16 +45,17 @@ /*---------------------------------------------------------------------* * Local function prototypes *---------------------------------------------------------------------*/ + static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, float output[][L_FRAME48k], const int16_t output_frame, const int32_t output_Fs ); static void TDREND_Clear_Update_flags( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd ); + /*---------------------------------------------------------------------* * ivas_td_binaural_open() * * Open and initialize TD Object binaural renderer *---------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error ivas_td_binaural_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -213,8 +214,7 @@ void ivas_td_binaural_close( * and renders the current frame. *---------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ -ivas_error ObjRenderIVASFrame( +void ObjRenderIVASFrame( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float output[][L_FRAME48k], /* i/o: SCE channels / Binaural synthesis */ const int16_t output_frame /* i : output frame length */ @@ -328,7 +328,8 @@ ivas_error ObjRenderIVASFrame( v_add( reverb_signal[1], output[1], output[1], output_frame ); } } - return IVAS_ERR_OK; + + return; } @@ -338,7 +339,6 @@ ivas_error ObjRenderIVASFrame( * Render one output frame from the mixer *---------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ static ivas_error TDREND_GetMix( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ float output[][L_FRAME48k], /* i/o: ISm object synth / rendered output in 0,1 */ @@ -350,10 +350,10 @@ static ivas_error TDREND_GetMix( TDREND_SRC_t *Src_p; TDREND_SRC_SPATIAL_t *SrcSpatial_p; TDREND_SRC_REND_t *SrcRend_p; - ivas_error result; + ivas_error error; float output_buf[2][L_FRAME48k]; /* Temp buffer for left/right rendered signal */ - result = IVAS_ERR_OK; + error = IVAS_ERR_OK; /* Zero out the output buffer since objects are accumulated. */ set_f( output_buf[0], 0.0f, output_frame ); @@ -377,9 +377,9 @@ static ivas_error TDREND_GetMix( if ( ( SrcRend_p->InputAvailable == TRUE ) && ( SrcRend_p->PlayStatus == TDREND_PLAYSTATUS_PLAYING ) ) { #ifdef TDREND_HRTF_TABLE_METHODS - result = TDREND_REND_RenderSourceHRFilt( Src_p, hBinRendererTd, output_buf, output_frame, output_Fs ); + error = TDREND_REND_RenderSourceHRFilt( Src_p, hBinRendererTd, output_buf, output_frame, output_Fs ); #else - result = TDREND_REND_RenderSourceHRFilt( Src_p, output_buf, output_frame, output_Fs ); + error = TDREND_REND_RenderSourceHRFilt( Src_p, output_buf, output_frame, output_Fs ); #endif } SrcRend_p->InputAvailable = FALSE; @@ -392,7 +392,7 @@ static ivas_error TDREND_GetMix( /* Clear the mixer update flags */ TDREND_Clear_Update_flags( hBinRendererTd ); - return result; + return error; } @@ -409,9 +409,11 @@ static void TDREND_Clear_Update_flags( int16_t i; hBinRendererTd->Listener_p->PoseUpdated = FALSE; + for ( i = 0; i < hBinRendererTd->NumOfSrcs; i++ ) { hBinRendererTd->Sources[i]->SrcSpatial_p->Updated = FALSE; } + return; } diff --git a/lib_dec/ivas_objectRenderer_hrFilt.c b/lib_dec/ivas_objectRenderer_hrFilt.c index fd2011a7d6..bb8f4f6ff4 100644 --- a/lib_dec/ivas_objectRenderer_hrFilt.c +++ b/lib_dec/ivas_objectRenderer_hrFilt.c @@ -352,7 +352,6 @@ ivas_error TDREND_REND_RenderSourceHRFilt( const int32_t output_Fs /* i : Output sample rate */ ) { - ivas_error SFX_Result; TDREND_SRC_REND_t *SrcRend_p; int16_t nS; float *InFrame_nIC_p; @@ -370,9 +369,7 @@ ivas_error TDREND_REND_RenderSourceHRFilt( /* SrcGain = Mix_p->Gain * ( *SrcRend_p->SrcGain_p ); */ /* SrcGain *= ( *SrcRend_p->DirGain_p ) * ( *SrcRend_p->DistGain_p ); */ - SFX_Result = TDREND_SFX_SpatBin_Execute_Main( SrcRend_p->SfxSpatBin_p, InFrame_nIC_p, output_frame, - LeftOutputFrame, RightOutputFrame, - &NoOfUsedInputSamples, &NoOfDeliveredOutputSamples, output_Fs ); + TDREND_SFX_SpatBin_Execute_Main( SrcRend_p->SfxSpatBin_p, InFrame_nIC_p, output_frame, LeftOutputFrame, RightOutputFrame, &NoOfUsedInputSamples, &NoOfDeliveredOutputSamples, output_Fs ); #ifdef TDREND_HRTF_TABLE_METHODS if ( hBinRendererTd->HrFiltSet_p->FilterMethod != TDREND_HRFILT_Method_BSplineModel ) @@ -392,7 +389,7 @@ ivas_error TDREND_REND_RenderSourceHRFilt( *RightAccOutputFrame_p++ += *RightOutputFrame_p++; } - return SFX_Result; + return IVAS_ERR_OK; } @@ -1333,7 +1330,7 @@ static float GreatCircleAngleDeg( { return acosf( sinf( El1 * PI_OVER_180 ) * sinf( El2 * PI_OVER_180 ) + cosf( El1 * PI_OVER_180 ) * cosf( El2 * PI_OVER_180 ) * - cosf( fabsf( Az1 - Az2 ) * PI_OVER_180 ) ) * + cosf( fabsf( Az1 - Az2 ) * PI_OVER_180 ) ) * PI_OVER_180; } #endif diff --git a/lib_dec/ivas_objectRenderer_mix.c b/lib_dec/ivas_objectRenderer_mix.c index 61553ca4fc..df190b91b1 100644 --- a/lib_dec/ivas_objectRenderer_mix.c +++ b/lib_dec/ivas_objectRenderer_mix.c @@ -46,8 +46,7 @@ * Sets the listener's position in the specified mixer unit. --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ -ivas_error TDREND_MIX_LIST_SetPos( +void TDREND_MIX_LIST_SetPos( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const float *Pos_p /* i : Listener's position */ ) @@ -65,7 +64,7 @@ ivas_error TDREND_MIX_LIST_SetPos( Listener_p->PoseUpdated = TRUE; } - return IVAS_ERR_OK; + return; } @@ -75,7 +74,6 @@ ivas_error TDREND_MIX_LIST_SetPos( * Sets the listener's orientation vectors in the specified mixer unit. --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_LIST_SetOrient( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const float *FrontVec_p, /* i : Listener's orientation front vector */ @@ -193,7 +191,6 @@ void TDREND_MIX_Dealloc( * Initializes the mixer and sets HRTF --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_Init( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ TDREND_HRFILT_FiltSet_t **hHrtfTD, /* i/o: HRTF data (initialized in case of NULL) */ @@ -256,7 +253,6 @@ ivas_error TDREND_MIX_Init( * Set the distance attenuation model of the mixer --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SetDistAttenModel( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const TDREND_DistAttenModel_t DistAttenModel /* i : Distance attenuation model */ @@ -291,7 +287,6 @@ ivas_error TDREND_MIX_SetDistAttenModel( * Adds the specified input source unit to the specified mixer unit. --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_AddSrc( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ int16_t *SrcInd, /* o : Source index */ diff --git a/lib_dec/ivas_objectRenderer_sfx.c b/lib_dec/ivas_objectRenderer_sfx.c index 57b2d52c80..381506e249 100644 --- a/lib_dec/ivas_objectRenderer_sfx.c +++ b/lib_dec/ivas_objectRenderer_sfx.c @@ -70,7 +70,7 @@ static void TDREND_FirFilterRev( float *OutputFrame_p, float *FirFilterRev_p, co #ifdef TDREND_HRTF_TABLE_METHODS static void TDREND_FirFilterRevInterp( float *OutputFrame_p, float *FirFilterRev_p, const int16_t FirFilterLength, float *InputFrame_p, const int16_t NumOfSamples, float *FilterStored ); #endif -static ivas_error TDREND_SFX_SpatBin_Clear( SFX_SpatBin_t *SfxSpatBin_p, const int32_t output_Fs ); +static void TDREND_SFX_SpatBin_Clear( SFX_SpatBin_t *SfxSpatBin_p, const int32_t output_Fs ); /*-------------------------------------------------------------------* @@ -352,8 +352,7 @@ static void TDREND_SFX_SpatBin_Resampling( * --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ -ivas_error TDREND_SFX_SpatBin_SetParams( +void TDREND_SFX_SpatBin_SetParams( SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct to be updated */ const SFX_SpatBin_Params_t *NewParam_p, /* i : New parameters struct */ const int32_t output_Fs /* i : Output sample rate */ @@ -397,7 +396,7 @@ ivas_error TDREND_SFX_SpatBin_SetParams( SfxSpatBin_p->OpMode = SFX_OFF; } - return IVAS_ERR_OK; + return; } @@ -554,6 +553,7 @@ static void TDREND_SFX_SpatBin_SetParamsInitializeOff( SfxSpatBin_p->NoOfLeftOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i]; SfxSpatBin_p->NoOfRightOldBufferSamples = SFX_SPAT_BIN_SINC_M - 1 + TDREND_MaxITD[i]; SfxSpatBin_p->Left_Tf = 0.0; + return; } @@ -925,11 +925,9 @@ static void TDREND_SFX_SpatBin_UpdateParams( * TDREND_SFX_SpatBin_Execute_Main() * * The main rendering function that is called from the Audio Mixer. - * --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ -ivas_error TDREND_SFX_SpatBin_Execute_Main( +void TDREND_SFX_SpatBin_Execute_Main( SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ const float *InBuffer_p, /* i : Input buffer */ const int16_t output_frame, /* i : frame length */ @@ -999,7 +997,7 @@ ivas_error TDREND_SFX_SpatBin_Execute_Main( TempNoOfInputSamples = TempNoOfInputSamples - TempNoOfUsedInputSamples; } - return IVAS_ERR_OK; + return; } @@ -1182,7 +1180,7 @@ static void TDREND_SFX_SpatBin_Execute( } /* Update number of old samples */ - SfxSpatBin_p->NoOfRightOldBufferSamples = *NoOfUsedInputSamples_p - (int16_t) Ind; + SfxSpatBin_p->NoOfRightOldBufferSamples = *NoOfUsedInputSamples_p - Ind; return; } @@ -1195,7 +1193,6 @@ static void TDREND_SFX_SpatBin_Execute( * --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_SFX_SpatBin_Initialize( SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ const int32_t output_Fs /* i : Output sampling rate */ @@ -1272,19 +1269,21 @@ ivas_error TDREND_SFX_SpatBin_Initialize( * --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ -static ivas_error TDREND_SFX_SpatBin_Clear( +static void TDREND_SFX_SpatBin_Clear( SFX_SpatBin_t *SfxSpatBin_p, /* i/o: Spatial parameters struct */ const int32_t output_Fs /* i : Output sample rate */ ) { int16_t i; int16_t MaxITD = TDREND_MaxITD[2]; + SfxSpatBin_p->OpMode = SFX_OFF; SfxSpatBin_p->TurningOffEffect = FALSE; SfxSpatBin_p->TurningOnEffect = FALSE; + /* Init during next SetParams-call */ SfxSpatBin_p->InitializeParams = TRUE; + /* Fill old buffers with zeros */ switch ( output_Fs ) { @@ -1310,7 +1309,7 @@ static ivas_error TDREND_SFX_SpatBin_Clear( SfxSpatBin_p->ResampledBufferRight[i] = 0.0f; } - return IVAS_ERR_OK; + return; } diff --git a/lib_dec/ivas_objectRenderer_sources.c b/lib_dec/ivas_objectRenderer_sources.c index b24708a195..a9e88602ca 100644 --- a/lib_dec/ivas_objectRenderer_sources.c +++ b/lib_dec/ivas_objectRenderer_sources.c @@ -55,14 +55,13 @@ static void TDREND_SRC_REND_Init( TDREND_SRC_REND_t *SrcRend_p, const int32_t ou /*-------------------------------------------------------------------* - * TDREND_MIX_SetSrcPos() + * TDREND_MIX_SRC_SetPos() * * Set source position --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetPos( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ const float *Vec_p /* i : Position vector */ ) @@ -94,7 +93,6 @@ ivas_error TDREND_MIX_SRC_SetPos( * Set source direciton --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetDir( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ @@ -129,7 +127,6 @@ ivas_error TDREND_MIX_SRC_SetDir( * Set directional attenuation for the mixer. --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetDirAtten( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ @@ -146,6 +143,7 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( SrcSpatial_p = hBinRendererTd->Sources[SrcInd]->SrcSpatial_p; TDREND_SRC_SPATIAL_SetDirAtten( SrcSpatial_p, DirAtten_p ); } + return IVAS_ERR_OK; } @@ -156,7 +154,6 @@ ivas_error TDREND_MIX_SRC_SetDirAtten( * Set play state for the source. --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_MIX_SRC_SetPlayState( BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ const int16_t SrcInd, /* i : Source index */ @@ -181,7 +178,6 @@ ivas_error TDREND_MIX_SRC_SetPlayState( * Renderer allocation --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ static ivas_error TDREND_SRC_REND_Alloc( TDREND_SRC_REND_t **SrcRend_pp /* i/o: Source object */ ) @@ -441,7 +437,6 @@ void TDREND_SRC_REND_UpdateFiltersFromSpatialParams( * Allocatie spatial properties of a source. --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ static ivas_error TDREND_SRC_SPATIAL_Alloc( TDREND_SRC_SPATIAL_t **SrcSpatial_pp /* i/o: Source spatial parameters */ ) @@ -651,7 +646,6 @@ static float TDREND_SRC_SPATIAL_GetDistGain( * Allocate a source. --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ ivas_error TDREND_SRC_Alloc( TDREND_SRC_t **Src_pp /* i/o: Source */ ) diff --git a/lib_util/hrtf_file_reader.c b/lib_util/hrtf_file_reader.c index 1dc481c84e..92b0058436 100644 --- a/lib_util/hrtf_file_reader.c +++ b/lib_util/hrtf_file_reader.c @@ -165,6 +165,7 @@ static void LoadBSplineBinaryITD( modelITD->W = (const float *) modelITD->W_dyn; modelITD->azimBsShape = (const float *) modelITD->azimBsShape_dyn; modelITD->elevBsShape = (const float *) modelITD->elevBsShape_dyn; + return; } @@ -310,7 +311,7 @@ static ivas_error LoadBSplineBinary( * * Load HRTF model or table from file --------------------------------------------------------------------*/ -/*! r: TD Renderer result code. */ + static ivas_error TDREND_MIX_LoadHRTF( FILE *f_hrtf, /* i/o: File pointer to HRTF file */ IVAS_DEC_HRTF_HANDLE HrFiltSet_p /* o : Loaded HR filter set */ -- GitLab From 0a986d177d26dd6d10fb9bfd769c9629b9c370f5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 1 Sep 2022 12:19:38 +0200 Subject: [PATCH 04/10] rename 'result' to 'gain' to clearly specify the variable used --- lib_com/ivas_spar_com.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib_com/ivas_spar_com.c b/lib_com/ivas_spar_com.c index 3c908c7980..46f6b3dc41 100755 --- a/lib_com/ivas_spar_com.c +++ b/lib_com/ivas_spar_com.c @@ -137,23 +137,23 @@ void ivas_get_twid_factors( float ivas_get_mdct_scaling_gain( const int16_t dct_len_by_2 ) { - float result = 0.0f; + float gain = 0.0f; switch ( dct_len_by_2 ) { case L_FRAME48k >> 2: { - result = IVAS_MDCT_SCALING_GAIN_48k; + gain = IVAS_MDCT_SCALING_GAIN_48k; break; } case L_FRAME32k >> 2: { - result = IVAS_MDCT_SCALING_GAIN_32k; + gain = IVAS_MDCT_SCALING_GAIN_32k; break; } case L_FRAME16k >> 2: { - result = IVAS_MDCT_SCALING_GAIN_16k; + gain = IVAS_MDCT_SCALING_GAIN_16k; break; } default: @@ -163,7 +163,7 @@ float ivas_get_mdct_scaling_gain( } } - return result; + return gain; } -- GitLab From e1d9a3b7de90c17192489436e86f34b238361edb Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 1 Sep 2022 12:36:39 +0200 Subject: [PATCH 05/10] typos + alignment --- lib_com/ivas_prot.h | 12 ++++++------ lib_com/ivas_stereo_mdct_stereo_com.c | 2 +- lib_com/prot.h | 4 ++-- lib_dec/acelp_core_switch_dec.c | 2 +- lib_dec/ivas_stereo_mdct_stereo_dec.c | 2 +- lib_dec/swb_tbe_dec.c | 2 +- lib_enc/ivas_mcmasa_enc.c | 5 ++--- lib_enc/lib_enc.c | 2 +- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 99989f2b07..15eb7d38b2 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -2155,7 +2155,7 @@ void stereo_mdct_core_dec( void splitAvailableBits( const int16_t total_bits, /* i : total available bits for TCX coding */ const int16_t split_ratio, /* i : split ratio */ - const int16_t isSBAStereoMode, /* i : signal core coding for sba */ + const int16_t isSBAStereoMode, /* i : signal core coding for SBA */ int16_t *bits_ch0, /* o : bits for channel 0 */ int16_t *bits_ch1 /* o : bits for channel 1 */ ); @@ -2173,7 +2173,7 @@ void parse_stereo_from_bitstream( STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo decoder structure */ Decoder_State **sts, /* i/o: decoder state structure */ const int16_t mct_on, /* i : flag mct block (1) or stereo (0) */ - const int16_t isSBAStereoMode, /* i: flag core coding for sba */ + const int16_t isSBAStereoMode, /* i : flag core coding for SBA */ Decoder_State *st0, /* i/o: decoder state structure for Bstr */ int16_t ms_mask[NB_DIV][MAX_SFB] /* o : bandwise MS mask */ ); @@ -4425,10 +4425,10 @@ void ivas_masa_prerender( void ivas_spar_param_to_masa_param_mapping( Decoder_Struct *st_ivas, /* i/o: IVAS decoder struct */ - float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i: Input audio in CLDFB domain, real */ - float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i: Input audio in CLDFB domain, imag */ - const int16_t firstSubframe, /* i: First subframe to map */ - const int16_t nSubframes /* i: Number of subframes to map */ + float inRe[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, real */ + float inIm[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* i : Input audio in CLDFB domain, imag */ + const int16_t firstSubframe, /* i : First subframe to map */ + const int16_t nSubframes /* i : Number of subframes to map */ ); diff --git a/lib_com/ivas_stereo_mdct_stereo_com.c b/lib_com/ivas_stereo_mdct_stereo_com.c index 73cd2fd579..cbb1423cd1 100644 --- a/lib_com/ivas_stereo_mdct_stereo_com.c +++ b/lib_com/ivas_stereo_mdct_stereo_com.c @@ -46,7 +46,7 @@ void splitAvailableBits( const int16_t total_bits, /* i : total available bits for TCX coding */ const int16_t split_ratio, /* i : split ratio */ - const int16_t isSBAStereoMode, /* i : signal core coding for sba */ + const int16_t isSBAStereoMode, /* i : signal core coding for SBA */ int16_t *bits_ch0, /* o : bits for channel 0 */ int16_t *bits_ch1 /* o : bits for channel 1 */ ) diff --git a/lib_com/prot.h b/lib_com/prot.h index d9a80e70e6..4c91c8cd52 100644 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -2777,7 +2777,7 @@ void fb_tbe_dec( const float fb_exc[], /* i : FB excitation from the SWB part */ float *hb_synth, /* i/o: high-band synthesis */ float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */ - const int16_t output_frame /* i: output frame length */ + const int16_t output_frame /* i : output frame length */ ); void calc_tilt_bwe( @@ -7181,7 +7181,7 @@ void WindowSignal( float out[], /* o : output windowed signal */ const int16_t truncate_aldo, /* i : nonzero to truncate long ALDO slope */ const int16_t fullband, /* i : fullband flag */ - const int16_t isLfe /* i: LFE flag */ + const int16_t isLfe /* i : LFE flag */ ); void HBAutocorrelation( diff --git a/lib_dec/acelp_core_switch_dec.c b/lib_dec/acelp_core_switch_dec.c index 9daac37b74..98854527e6 100644 --- a/lib_dec/acelp_core_switch_dec.c +++ b/lib_dec/acelp_core_switch_dec.c @@ -534,7 +534,7 @@ ivas_error acelp_core_switch_dec_bfi( /*-------------------------------------------------------------------* * decod_gen_voic_core_switch() * - * Decode excitation signal in teh first ACELP->HQ switching frame + * Decode excitation signal in the first ACELP->HQ switching frame *-------------------------------------------------------------------*/ static void decod_gen_voic_core_switch( diff --git a/lib_dec/ivas_stereo_mdct_stereo_dec.c b/lib_dec/ivas_stereo_mdct_stereo_dec.c index f797eaf289..064784e705 100644 --- a/lib_dec/ivas_stereo_mdct_stereo_dec.c +++ b/lib_dec/ivas_stereo_mdct_stereo_dec.c @@ -57,7 +57,7 @@ void parse_stereo_from_bitstream( STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo decoder structure */ Decoder_State **sts, /* i/o: decoder state structure */ const int16_t mct_on, /* i : flag mct block (1) or stereo (0)*/ - const int16_t isSBAStereoMode, /* i : flag core coding for sba */ + const int16_t isSBAStereoMode, /* i : flag core coding for SBA */ Decoder_State *st0, /* i/o: decoder state structure for Bstr*/ int16_t ms_mask[NB_DIV][MAX_SFB] /* o : bandwise MS mask */ ) diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index 806cc27041..2664aaa08d 100755 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -1977,7 +1977,7 @@ void fb_tbe_dec( const float fb_exc[], /* i : FB excitation from the SWB part */ float *hb_synth, /* o : high-band synthesis */ float *fb_synth_ref, /* o : high-band synthesis 16-20 kHz */ - const int16_t output_frame /* i: output frame length */ + const int16_t output_frame /* i : output frame length */ ) { int16_t i; diff --git a/lib_enc/ivas_mcmasa_enc.c b/lib_enc/ivas_mcmasa_enc.c index 595f758e51..8be1836de5 100644 --- a/lib_enc/ivas_mcmasa_enc.c +++ b/lib_enc/ivas_mcmasa_enc.c @@ -70,9 +70,8 @@ static void ivas_mcmasa_dmx( MCMASA_ENC_HANDLE hMcMasa, float data_f[][L_FRAME48 static void compute_cov_mtx( float sr[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], float si[MCMASA_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], const int16_t freq, const int16_t N, CovarianceMatrix *COVls ); -static void computeIntensityVector_enc( const int16_t *band_grouping, float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], const int16_t enc_param_start_band, /* i: first band to process */ - const int16_t num_frequency_bands, - float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] ); +static void computeIntensityVector_enc( const int16_t *band_grouping, float Cldfb_RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], float Cldfb_ImagBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], + const int16_t enc_param_start_band, const int16_t num_frequency_bands, float intensity_real[DIRAC_NUM_DIMS][MASA_FREQUENCY_BANDS] ); static void computeVerticalDiffuseness( float **buffer_intensity, const float *buffer_energy, const int16_t averaging_length, const int16_t num_freq_bands, float *diffuseness ); diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 1ffe8007f4..3ca180067d 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -951,7 +951,7 @@ ivas_error IVAS_ENC_GetDelay( *---------------------------------------------------------------------*/ static int16_t getInputBufferSize( - const Encoder_Struct *st_ivas /* i: IVAS encoder handle */ + const Encoder_Struct *st_ivas /* i : IVAS encoder handle */ ) { return (int16_t) ( st_ivas->hEncoderConfig->input_Fs * st_ivas->hEncoderConfig->nchan_inp / FRAMES_PER_SEC ); -- GitLab From 0f3f2f912f2298a51378bd513d2531ffc30319eb Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 1 Sep 2022 12:49:47 +0200 Subject: [PATCH 06/10] data type change: int -> int16_t --- lib_enc/ivas_spar_encoder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index abe392c390..20c5912c49 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -819,14 +819,14 @@ static ivas_error ivas_spar_enc_process( if ( hSpar->hPCA != NULL ) { #ifdef SPAR_SCALING_HARMONIZATION - for ( int out_ch = 0; out_ch < FOA_CHANNELS; out_ch++ ) + for ( int16_t out_ch = 0; out_ch < FOA_CHANNELS; out_ch++ ) { v_multc( p_pcm_tmp[out_ch], MDFT_NORM_SCALING, p_pcm_tmp[out_ch], input_frame ); } #endif ivas_pca_enc( hEncoderConfig, hSpar->hPCA, hMetaData, p_pcm_tmp, input_frame, FOA_CHANNELS ); #ifdef SPAR_SCALING_HARMONIZATION - for ( int out_ch = 0; out_ch < FOA_CHANNELS; out_ch++ ) + for ( int16_t out_ch = 0; out_ch < FOA_CHANNELS; out_ch++ ) { v_multc( p_pcm_tmp[out_ch], PCM16_TO_FLT_FAC, p_pcm_tmp[out_ch], input_frame ); } -- GitLab From c176ff4aff9b428b8e0e9282df4ee888bc64d230 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 1 Sep 2022 12:50:28 +0200 Subject: [PATCH 07/10] delete obsolete stereo mode specification in help --- apps/encoder.c | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/encoder.c b/apps/encoder.c index 47a6d42e30..b1abc36d2f 100755 --- a/apps/encoder.c +++ b/apps/encoder.c @@ -1618,7 +1618,7 @@ static void usage_enc( void ) fprintf( stdout, " where 0 = adaptive, 3-100 = fixed in number of frames,\n" ); fprintf( stdout, " default is deactivated\n" ); fprintf( stdout, "-dtx : Activate DTX mode with a SID update rate of 8 frames\n" ); - fprintf( stdout, " Note: DTX is currently supported in EVS, DFT/TD stereo, 1 ISm, \n" ); + fprintf( stdout, " Note: DTX is currently supported in EVS, stereo, 1 ISm, \n" ); fprintf( stdout, " SBA (up to 128kbps) and MASA (up to 128kbps)\n" ); fprintf( stdout, "-rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" ); fprintf( stdout, " where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" ); diff --git a/readme.txt b/readme.txt index 4d4de5864a..86e223b32c 100644 --- a/readme.txt +++ b/readme.txt @@ -195,7 +195,7 @@ EVS mono is default, for IVAS choose one of the following: -stereo, -ism, -sba, where 0 = adaptive, 3-100 = fixed in number of frames, default is deactivated -dtx : Activate DTX mode with a SID update rate of 8 frames - Note: DTX is currently supported in EVS, DFT/TD stereo, 1 ISm, + Note: DTX is currently supported in EVS, stereo, 1 ISm, SBA (up to 128kbps) and MASA (up to 128kbps) -rf p o : Activate channel-aware mode for WB and SWB signal at 13.2kbps, where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames. -- GitLab From 3e2f012782a66897f7deb284a615f5f6e6c1b45f Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 2 Sep 2022 09:24:40 +0200 Subject: [PATCH 08/10] formatting --- lib_com/ivas_rom_com.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 6e101da897..072eb56f50 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -903,11 +903,11 @@ 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, 1, 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 }},{ { 21, 1, 5, 1 },{ 15, 1, 5, 1 },{ 15, 1, 3, 1 } }, 0, 0, 0 }, + { 32000, 0, 1, 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 } }, { { 15, 7, 5, 1 },{ 15, 7, 3, 1 },{ 7, 7, 3, 1 } }, 1, 0, 0 }, @@ -955,8 +955,6 @@ const ivas_spar_br_table_t ivas_spar_br_table_consts[IVAS_SPAR_BR_TABLE_LEN] = { 512000, 0, 3, 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 }, - - }; const ivas_freq_models_t ivas_arith_pred_r_consts[TOTAL_PRED_QUANT_STRATS_ARITH] = @@ -1136,7 +1134,7 @@ const ivas_freq_models_t ivas_arith_pred_r_consts[TOTAL_PRED_QUANT_STRATS_ARITH] } }; - const ivas_freq_models_t ivas_arith_drct_r_consts[TOTAL_DRCT_QUANT_STRATS] = +const ivas_freq_models_t ivas_arith_drct_r_consts[TOTAL_DRCT_QUANT_STRATS] = { /* entry for 1 quantization points */ { @@ -1223,7 +1221,7 @@ const ivas_freq_models_t ivas_arith_pred_r_consts[TOTAL_PRED_QUANT_STRATS_ARITH] } }; - const ivas_freq_models_t ivas_arith_decd_r_consts[TOTAL_DECD_QUANT_STRATS] = +const ivas_freq_models_t ivas_arith_decd_r_consts[TOTAL_DECD_QUANT_STRATS] = { /* entry for 1 quantization points */ { -- GitLab From 22e37c8aef8731ef074d7d18a278e56ce9ec1cc5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 2 Sep 2022 09:34:51 +0200 Subject: [PATCH 09/10] formatting --- lib_com/ivas_prot.h | 18 ++++++++---------- lib_com/options.h | 11 +++-------- lib_enc/ivas_spar_md_enc.c | 7 +++---- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index ec81ed9337..88e83ded12 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1845,7 +1845,7 @@ void TNSAnalysisStereo( int16_t tnsSize[MCT_MAX_CHANNELS][NB_DIV], /* i : number of tns parameters put into prm */ int16_t tnsBits[MCT_MAX_CHANNELS][NB_DIV], /* i : number of tns bits in the frame */ int16_t param_core[][NB_DIV * NPRM_DIV], /* o : quantized noise filling level */ - const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ + const int16_t mct_on /* i : flag mct block (1) or stereo (0) */ ); void InternalTCXDecoder( @@ -2013,7 +2013,7 @@ void decoder_tcx_imdct( const int16_t left_rect, float x[N_MAX], float xn_buf[], - const uint16_t kernelType, /* i : TCX transform kernel type */ + const uint16_t kernelType, /* i : TCX transform kernel type */ const int16_t fUseTns, /* i : flag that is set if TNS data is present */ float synth[], /* i/o: synth[-M..L_frame] */ float synthFB[], @@ -3864,8 +3864,7 @@ void ivas_spar_dec_upmixer( /* MD module */ ivas_error ivas_spar_md_enc_open( ivas_spar_md_enc_state_t **hMdEnc, /* i/o: SPAR MD encoder handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ - , + const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ const int16_t sba_order /* i : Ambisonic (SBA) order */ ); @@ -3878,8 +3877,7 @@ ivas_error ivas_spar_md_enc_process( const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ ivas_spar_md_enc_in_buf_t *pIn_buf, BSTR_ENC_HANDLE hMetaData, /* i/o: MetaData handle */ - const int16_t dtx_silence_mode - , + const int16_t dtx_silence_mode, const int16_t sba_order /* i : Ambisonic (SBA) order */ ); @@ -4634,9 +4632,9 @@ void vbap_determine_gains( ); void v_sort_ind( - float *x, /* i/o: Vector to be sorted */ - int16_t *idx, /* o : Original index positions */ - const int16_t len /* i : vector length */ + float *x, /* i/o: Vector to be sorted */ + int16_t *idx, /* o : Original index positions */ + const int16_t len /* i : vector length */ ); /*----------------------------------------------------------------------------------* @@ -4671,7 +4669,7 @@ void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ float Cldfb_RealBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ float Cldfb_ImagBuffer_InOut[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /* i/o: LS signals */ - int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */ + int16_t channel_active[MAX_CICP_CHANNELS] /* i : bitmap indicating which output channels are active */ ); diff --git a/lib_com/options.h b/lib_com/options.h index 567f131a89..bce8d45d02 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -146,15 +146,10 @@ /*#define FIX_IVAS_185_MDCT_ST_PLC_FADEOUT*/ /* IVAS-185 fix bug in TCX-PLC fadeout for MDCT-Stereo and improve fadeout by fading to background noise instead of white noise */ /*#define FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ - - #define FIX_ADAP_STEFI_SHIFT /* Issue 89: fix bug in parameter shift of adaptive stereo filling */ - - - -/* NTT switches */ - #define SPAR_SCALING_HARMONIZATION /* issue 80: Changes to harmonize scaling in spar */ -/* ################## End DEVELOPMENT switches ######################### */ + + + /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ #endif diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index ef7f7c5b63..485d98da5b 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -106,10 +106,9 @@ static void ivas_quant_pred_coeffs_per_band( ivas_band_coeffs_t *pband_coeffs, i *------------------------------------------------------------------------*/ ivas_error ivas_spar_md_enc_open( - ivas_spar_md_enc_state_t **hMdEnc_in, /* i/o: SPAR MD encoder handle */ - const ENCODER_CONFIG_HANDLE hEncoderConfig /* i : configuration structure */ - , - const int16_t sba_order /* i : Ambisonic (SBA) order */ + ivas_spar_md_enc_state_t **hMdEnc_in, /* i/o: SPAR MD encoder handle */ + const ENCODER_CONFIG_HANDLE hEncoderConfig, /* i : configuration structure */ + const int16_t sba_order /* i : Ambisonic (SBA) order */ ) { ivas_spar_md_enc_state_t *hMdEnc; -- GitLab From 69ff8238dce28ebc5914d09057f307e90659fa38 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 2 Sep 2022 10:07:27 +0200 Subject: [PATCH 10/10] maintenance: - typos - rename pState -> hMdEnc/hMdDec - add "VE2DB" comments --- lib_com/bitstream.c | 10 +- lib_com/ivas_fb_mixer.c | 4 +- lib_com/ivas_spar_com_quant_util.c | 6 +- lib_com/ivas_stat_com.h | 4 +- lib_dec/ivas_cpe_dec.c | 2 +- lib_dec/ivas_qmetadata_dec.c | 6 +- lib_dec/ivas_spar_decoder.c | 8 +- lib_dec/ivas_spar_md_dec.c | 447 ++++++++++++++--------------- lib_dec/ivas_stat_dec.h | 2 +- lib_enc/ivas_qmetadata_enc.c | 2 +- lib_enc/ivas_spar_encoder.c | 6 +- lib_enc/ivas_spar_md_enc.c | 219 +++++++------- 12 files changed, 356 insertions(+), 360 deletions(-) diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index 73547bbbe8..761ad816bd 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -2063,7 +2063,7 @@ ivas_error read_indices( } else if ( k == SIZE_IVAS_BRATE_TBL ) { - /*temp change for spar DTX*/ + /*temp change for SPAR DTX*/ if ( total_brate == IVAS_SID_5k ) { st_ivas->element_mode_init = -1; @@ -2116,7 +2116,7 @@ ivas_error read_indices( } else { - sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases , a corrupt sid frames */ + sid_upd_bad = 1; /* this frame type may happen in ETSI/3GPP CS cases, a corrupt SID frames */ } } @@ -2201,7 +2201,7 @@ ivas_error read_indices( /* total_brate= 0 */ } - /* handle bad/lost speech frame(and CS bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ + /* handle bad/lost speech frame(and CS bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ if ( ( ( *CNG != 0 ) && ( ( speech_bad != 0 ) || ( speech_lost != 0 ) ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ ( sid_upd_bad != 0 ) ) /* SID_UPD_BAD --> start CNG */ { @@ -2320,7 +2320,7 @@ static Word32 read_indices_mime_handle_dtx( { if ( st->bfi ) { - sid_upd_bad = 1; /* corrupt sid_first, signaled as bad sid */ + sid_upd_bad = 1; /* corrupt sid_first, signaled as bad SID */ } else { @@ -2378,7 +2378,7 @@ static Word32 read_indices_mime_handle_dtx( } /* in CNG */ - /* handle bad speech frame(and bad sid frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ + /* handle bad speech frame(and bad SID frame) in the decoders CNG synthesis settings pair (total_brate, bfi) */ if ( ( *CNG != 0 && ( speech_bad || speech_lost || no_data ) ) || /* SP_BAD or SPEECH_LOST) --> stay in CNG */ sid_upd_bad ) /* SID_UPD_BAD --> start/stay CNG */ { diff --git a/lib_com/ivas_fb_mixer.c b/lib_com/ivas_fb_mixer.c index 11746c64ef..53ad90d01f 100644 --- a/lib_com/ivas_fb_mixer.c +++ b/lib_com/ivas_fb_mixer.c @@ -1098,8 +1098,8 @@ static ivas_error ivas_filterbank_setup( for ( j = 0; j < IVAS_MAX_NUM_FB_BANDS; j++ ) { - pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j] = 0; /* aka num_active_bins per spar band */ - pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[j] = 0; /* first considered bin index per spar band */ + pFb->fb_bin_to_band.p_short_stride_num_bins_per_band[j] = 0; /* aka num_active_bins per SPAR band */ + pFb->fb_bin_to_band.p_short_stride_start_bin_per_band[j] = 0; /* first considered bin index per SPAR band */ pFb->fb_bin_to_band.pp_short_stride_bin_to_band[j] = NULL; for ( i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) { diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index 9b0a936018..5755f05324 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -259,7 +259,7 @@ void ivas_map_prior_coeffs_quant( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_quant_dtx_init() * - * Init spar md with minmax vals + * Init SPAR MD with minmax vals *-----------------------------------------------------------------------------------------*/ void ivas_spar_quant_dtx_init( @@ -347,7 +347,7 @@ void ivas_copy_band_coeffs_idx_to_arr( /*-----------------------------------------------------------------------------------------* * Function ivas_clear_band_coeffs() * - * clear band coeffs array in spar MD + * clear band coeffs array in SPAR MD *-----------------------------------------------------------------------------------------*/ void ivas_clear_band_coeffs( @@ -374,7 +374,7 @@ void ivas_clear_band_coeffs( /*-----------------------------------------------------------------------------------------* * Function ivas_clear_band_coeff_idx() * - * clear band coeffs index array in spar MD + * clear band coeffs index array in SPAR MD *-----------------------------------------------------------------------------------------*/ void ivas_clear_band_coeff_idx( diff --git a/lib_com/ivas_stat_com.h b/lib_com/ivas_stat_com.h index 8c54421f04..e19d30dc71 100644 --- a/lib_com/ivas_stat_com.h +++ b/lib_com/ivas_stat_com.h @@ -692,8 +692,8 @@ typedef struct ivas_fb_bin_to_band_data_t float *pFb_bin_to_band[IVAS_MAX_NUM_FB_BANDS]; const int16_t *pFb_start_bin_per_band; const int16_t *pFb_active_bins_per_band; - float pp_cldfb_weights_per_spar_band[CLDFB_NO_CHANNELS_MAX][IVAS_MAX_NUM_FB_BANDS]; /* weights for linear combination of parameters from different spar bands*/ - int16_t p_spar_start_bands[CLDFB_NO_CHANNELS_MAX]; /* the first spar band per CLFB band when the weight is > 0 */ + float pp_cldfb_weights_per_spar_band[CLDFB_NO_CHANNELS_MAX][IVAS_MAX_NUM_FB_BANDS]; /* weights for linear combination of parameters from different SPAR bands*/ + int16_t p_spar_start_bands[CLDFB_NO_CHANNELS_MAX]; /* the first SPAR band per CLFB band when the weight is > 0 */ int16_t p_cldfb_map_to_spar_band[CLDFB_NO_CHANNELS_MAX]; /* a direct mapping from CLDFB band to SPAR band */ int16_t p_short_stride_start_bin_per_band[IVAS_MAX_NUM_FB_BANDS]; int16_t p_short_stride_num_bins_per_band[IVAS_MAX_NUM_FB_BANDS]; diff --git a/lib_dec/ivas_cpe_dec.c b/lib_dec/ivas_cpe_dec.c index 7223b38761..680839e121 100644 --- a/lib_dec/ivas_cpe_dec.c +++ b/lib_dec/ivas_cpe_dec.c @@ -951,7 +951,7 @@ static void read_stereo_mode_and_bwidth( hCPE->element_mode = IVAS_CPE_MDCT; break; case SID_SBA_1TC: - assert( "Forbidden value for sid format in CPE (SBA 1TC), should have already been adressed earlier" ); + assert( "Forbidden value for SID format in CPE (SBA 1TC), should have already been adressed earlier" ); break; case SID_MASA_1TC: hCPE->element_mode = IVAS_SCE; diff --git a/lib_dec/ivas_qmetadata_dec.c b/lib_dec/ivas_qmetadata_dec.c index 628e4ca6b8..2270d32eba 100644 --- a/lib_dec/ivas_qmetadata_dec.c +++ b/lib_dec/ivas_qmetadata_dec.c @@ -860,9 +860,9 @@ int16_t ivas_qmetadata_dec_sid_decode( #ifdef DEBUG_MODE_QMETADATA fprintf( pF, "frame %d: all %d ", frame, start_index - *index ); - fprintf( pF_azi, "frame %d sid: ", frame ); - fprintf( pF_ele, "frame %d sid: ", frame ); - fprintf( pF_ratio, "frame %d sid: ", frame ); + fprintf( pF_azi, "frame %d SID: ", frame ); + fprintf( pF_ele, "frame %d SID: ", frame ); + fprintf( pF_ratio, "frame %d SID: ", frame ); for ( b = start_band; b < nbands; b++ ) { diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index c781fa862c..4f48e10a09 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -966,7 +966,7 @@ void ivas_spar_dec_upmixer( * PCA decoder *---------------------------------------------------------------------*/ #ifdef DEBUG_SBA_AUDIO_DUMP - pState->pca_ingest_channels = num_in_ingest; + hSpar->pca_ingest_channels = num_in_ingest; #endif if ( hSpar->hPCA != NULL ) @@ -1169,7 +1169,7 @@ void ivas_spar_dec_upmixer( } } #ifdef DEBUG_SBA_AUDIO_DUMP - pState->numOutChannels = outchannels; + hSpar->numOutChannels = outchannels; #endif } else @@ -1188,12 +1188,12 @@ void ivas_spar_dec_upmixer( } } #ifdef DEBUG_SBA_AUDIO_DUMP - pState->numOutChannels = numch_out_dirac; + hSpar->numOutChannels = numch_out_dirac; #endif } #ifdef DEBUG_SBA_AUDIO_DUMP /* Dump audio signal after cldfbSynthesis */ - ivas_spar_dump_signal_wav( output_frame, NULL, output, pState->numOutChannels, spar_foa_dec_wav[3], "cldfbSynthesis()" ); + ivas_spar_dump_signal_wav( output_frame, NULL, output, hSpar->numOutChannels, spar_foa_dec_wav[3], "cldfbSynthesis()" ); #endif split_band = SPAR_DIRAC_SPLIT_START_BAND; diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index 6d6c1ca427..e597ced274 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -63,11 +63,11 @@ static const int16_t ivas_spar_dec_plc_spatial_target[IVAS_SPAR_MAX_CH] = { 1, 0 * Static functions declaration *------------------------------------------------------------------------------------------*/ -static void ivas_get_spar_matrices( ivas_spar_md_dec_state_t *pState, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t sba_order ); +static void ivas_get_spar_matrices( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, const int16_t dtx_vad, const int16_t nB, const int16_t sba_order ); -static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *pState, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw, int16_t *pDo_diff, const int16_t freq_diff, const int16_t planarCP ); +static void ivas_decode_arith_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw, int16_t *pDo_diff, const int16_t freq_diff, const int16_t planarCP ); -static void ivas_decode_huffman_bs( ivas_spar_md_dec_state_t *pState, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw, const int16_t planarCP ); +static void ivas_decode_huffman_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, const uint16_t qsi, const int16_t nB, const int16_t bands_bw, const int16_t planarCP ); static void ivas_fill_band_coeffs_idx( ivas_band_coeffs_ind_t *pBands_idx, const int16_t nB, int16_t *pSymbol_re, ivas_cell_dim_t *pCell_dims, ivas_coeffs_type_t coeff_type, const int16_t planarCP ); @@ -75,11 +75,11 @@ static void ivas_get_band_idx_from_differential( ivas_spar_md_t *pSpar_md, const static void ivas_mat_col_rearrange( float in_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], const int16_t order[IVAS_SPAR_MAX_CH], const int16_t i_ts, float ***mixer_mat, const int16_t bands, const int16_t num_ch ); -static void ivas_spar_dec_compute_ramp_down_post_matrix( ivas_spar_md_dec_state_t *pState, const int16_t num_bands, const int16_t bfi ); +static void ivas_spar_dec_compute_ramp_down_post_matrix( ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands, const int16_t bfi ); -static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coeffs, ivas_spar_dec_matrices_t *pSpar_coeffs_prev, int16_t *valid_bands, int16_t *base_band_age, const int16_t num_bands, const int16_t sba_order ); +static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coeffs, ivas_spar_dec_matrices_t *pSpar_coeffs_prev, const int16_t *valid_bands, int16_t *base_band_age, const int16_t num_bands, const int16_t sba_order ); -static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *pState, const int16_t nchan_transport, float *pFC ); +static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC ); static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band ); @@ -426,7 +426,7 @@ void ivas_spar_md_dec_close( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_md_dec_init() * - * Init call for md dec process + * SPAR MD decoder initialization *-----------------------------------------------------------------------------------------*/ ivas_error ivas_spar_md_dec_init( @@ -438,12 +438,11 @@ ivas_error ivas_spar_md_dec_init( int16_t i, j, k; int16_t nchan_transport; float pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; - ivas_spar_md_dec_state_t *pState = hMdDec; - pState->spar_md_cfg.gen_bs = 1; - ivas_spar_set_bitrate_config( &pState->spar_md_cfg, pState->table_idx, min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ) ); + hMdDec->spar_md_cfg.gen_bs = 1; // VE2DB : always 1 - can it be removed? + ivas_spar_set_bitrate_config( &hMdDec->spar_md_cfg, hMdDec->table_idx, min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ) ); - nchan_transport = pState->spar_md_cfg.nchan_transport; + nchan_transport = hMdDec->spar_md_cfg.nchan_transport; /* get FB coefficients */ for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) @@ -451,28 +450,28 @@ ivas_error ivas_spar_md_dec_init( pFC[i] = ivas_fb_fcs_12band_1ms[i] * hDecoderConfig->output_Fs * 0.5f; } - ivas_spar_set_dec_config( pState, nchan_transport, pFC ); + ivas_spar_set_dec_config( hMdDec, nchan_transport, pFC ); - if ( nchan_transport != 2 && ( ( pState->spar_md_cfg.remix_unmix_order == 2 ) || ( pState->spar_md_cfg.remix_unmix_order == 1 ) ) ) + if ( nchan_transport != 2 && ( ( hMdDec->spar_md_cfg.remix_unmix_order == 2 ) || ( hMdDec->spar_md_cfg.remix_unmix_order == 1 ) ) ) { return IVAS_ERR_INTERNAL; } /* DTX quant init */ - PR_minmax[0] = pState->spar_md_cfg.quant_strat[0].PR.min; - PR_minmax[1] = pState->spar_md_cfg.quant_strat[0].PR.max; - ivas_spar_quant_dtx_init( &pState->spar_md, PR_minmax ); + PR_minmax[0] = hMdDec->spar_md_cfg.quant_strat[0].PR.min; + PR_minmax[1] = hMdDec->spar_md_cfg.quant_strat[0].PR.max; + ivas_spar_quant_dtx_init( &hMdDec->spar_md, PR_minmax ); - ivas_spar_arith_coeffs_com_init( &pState->arith_coeffs, &pState->spar_md_cfg, pState->table_idx, DEC ); - ivas_spar_huff_coeffs_com_init( &pState->huff_coeffs, &pState->spar_md_cfg, pState->table_idx, DEC ); + ivas_spar_arith_coeffs_com_init( &hMdDec->arith_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC ); + ivas_spar_huff_coeffs_com_init( &hMdDec->huff_coeffs, &hMdDec->spar_md_cfg, hMdDec->table_idx, DEC ); - pState->spar_md_cfg.prev_quant_idx = -1; + hMdDec->spar_md_cfg.prev_quant_idx = -1; /* initialize PLC state */ - set_s( pState->valid_bands, 0, IVAS_MAX_NUM_BANDS ); - set_s( pState->base_band_age, 0, IVAS_MAX_NUM_BANDS ); - pState->spar_plc_num_lost_frames = 0; - pState->spar_plc_enable_fadeout_flag = 1; + set_s( hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS ); + set_s( hMdDec->base_band_age, 0, IVAS_MAX_NUM_BANDS ); + hMdDec->spar_plc_num_lost_frames = 0; + hMdDec->spar_plc_enable_fadeout_flag = 1; for ( i = 0; i < num_channels; i++ ) { @@ -480,7 +479,7 @@ ivas_error ivas_spar_md_dec_init( { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { - pState->spar_coeffs_prev.C_re[i][j][k] = 0; + hMdDec->spar_coeffs_prev.C_re[i][j][k] = 0; } } } @@ -491,7 +490,7 @@ ivas_error ivas_spar_md_dec_init( { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { - pState->spar_coeffs_prev.P_re[i][j][k] = 0; + hMdDec->spar_coeffs_prev.P_re[i][j][k] = 0; } } } @@ -502,7 +501,7 @@ ivas_error ivas_spar_md_dec_init( { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { - pState->spar_coeffs_tar.C_re[i][j][k] = 0; + hMdDec->spar_coeffs_tar.C_re[i][j][k] = 0; } } } @@ -513,24 +512,24 @@ ivas_error ivas_spar_md_dec_init( { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { - pState->spar_coeffs_tar.P_re[i][j][k] = 0; + hMdDec->spar_coeffs_tar.P_re[i][j][k] = 0; } } } - pState->dtx_md_smoothing_cntr = 1; + hMdDec->dtx_md_smoothing_cntr = 1; - ivas_clear_band_coeffs( pState->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); - ivas_clear_band_coeff_idx( pState->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); - ivas_clear_band_coeff_idx( pState->spar_md_prev.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); - ivas_clear_band_coeff_idx( pState->spar_md_prev.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeffs( hMdDec->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeff_idx( hMdDec->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeff_idx( hMdDec->spar_md_prev.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS ); - pState->spar_md.dtx_vad = 0; - pState->spar_md.num_bands = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); - pState->td_decorr_flag = 1; + hMdDec->spar_md.dtx_vad = 0; + hMdDec->spar_md.num_bands = min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + hMdDec->td_decorr_flag = 1; - set_f( pState->spar_md.en_ratio_slow, 0.0f, IVAS_MAX_NUM_BANDS ); - set_f( pState->spar_md.ref_pow_slow, 0.0f, IVAS_MAX_NUM_BANDS ); + set_f( hMdDec->spar_md.en_ratio_slow, 0.0f, IVAS_MAX_NUM_BANDS ); + set_f( hMdDec->spar_md.ref_pow_slow, 0.0f, IVAS_MAX_NUM_BANDS ); return IVAS_ERR_OK; } @@ -539,11 +538,11 @@ ivas_error ivas_spar_md_dec_init( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_set_dec_config() * - * Set configuration for SPAR md dec + * Set configuration for SPAR MD decoder *-----------------------------------------------------------------------------------------*/ static ivas_error ivas_spar_set_dec_config( - ivas_spar_md_dec_state_t *pState, + ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC ) { @@ -551,31 +550,31 @@ static ivas_error ivas_spar_set_dec_config( for ( i = 0; i < nchan_transport; i++ ) { - pState->spar_md_cfg.max_freq_per_chan[i] = ivas_spar_br_table_consts[pState->table_idx].fpcs; + hMdDec->spar_md_cfg.max_freq_per_chan[i] = ivas_spar_br_table_consts[hMdDec->table_idx].fpcs; } - nchan = ivas_sba_get_nchan_metadata( ivas_spar_br_table_consts[pState->table_idx].sba_order ); + nchan = ivas_sba_get_nchan_metadata( ivas_spar_br_table_consts[hMdDec->table_idx].sba_order ); switch ( nchan ) { case 4: /* FOA_CHANNELS */ - pState->num_decorr = IVAS_TD_DECORR_OUT_3CH; + hMdDec->num_decorr = IVAS_TD_DECORR_OUT_3CH; break; case 9: /* IVAS_HOA_2_CH */ // VE: is this relevant? - pState->num_decorr = IVAS_TD_DECORR_OUT_5CH; + hMdDec->num_decorr = IVAS_TD_DECORR_OUT_5CH; break; case 16: /* IVAS_HOA_3_CH */ // VE: is this relevant? - pState->num_decorr = IVAS_TD_DECORR_OUT_12CH; + hMdDec->num_decorr = IVAS_TD_DECORR_OUT_12CH; break; case 6: /* IVAS_HOA_2_CH */ - pState->num_decorr = IVAS_TD_DECORR_OUT_2CH; + hMdDec->num_decorr = IVAS_TD_DECORR_OUT_2CH; break; case 8: /* IVAS_HOA_3_CH */ - pState->num_decorr = IVAS_TD_DECORR_OUT_4CH; + hMdDec->num_decorr = IVAS_TD_DECORR_OUT_4CH; break; } - pState->spar_md_cfg.num_umx_chs = nchan; + hMdDec->spar_md_cfg.num_umx_chs = nchan; dmx_ch = 0; for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) @@ -583,17 +582,17 @@ static ivas_error ivas_spar_set_dec_config( dmx_ch = 0; for ( j = 0; j < nchan_transport; j++ ) { - if ( pFC[i] < pState->spar_md_cfg.max_freq_per_chan[j] ) + if ( pFC[i] < hMdDec->spar_md_cfg.max_freq_per_chan[j] ) { dmx_ch += 1; } } - pState->spar_md_cfg.num_dmx_chans_per_band[i] = pState->spar_md_cfg.nchan_transport; - pState->spar_md_cfg.num_decorr_per_band[i] = nchan - pState->spar_md_cfg.nchan_transport; + hMdDec->spar_md_cfg.num_dmx_chans_per_band[i] = hMdDec->spar_md_cfg.nchan_transport; + hMdDec->spar_md_cfg.num_decorr_per_band[i] = nchan - hMdDec->spar_md_cfg.nchan_transport; } - pState->spar_md_cfg.nchan_transport = dmx_ch; + hMdDec->spar_md_cfg.nchan_transport = dmx_ch; return IVAS_ERR_OK; } @@ -612,8 +611,10 @@ void ivas_spar_md_dec_process( const int16_t sba_order /* i : Ambisonic (SBA) order */ ) { - int16_t j, b, bw, dtx_vad, nB, i_ts; - ivas_spar_md_dec_state_t *hMdDec = st_ivas->hSpar->hMdDec; + int16_t j, k, b, bw, dtx_vad, nB, i_ts; + ivas_spar_md_dec_state_t *hMdDec; + + hMdDec = st_ivas->hSpar->hMdDec; ivas_spar_dec_parse_md_bs( hMdDec, st0, &nB, &bw, &dtx_vad, st_ivas->hDecoderConfig->ivas_total_brate, ivas_spar_br_table_consts[hMdDec->table_idx].usePlanarCoeff, st_ivas->hQMetaData->sba_inactive_mode ); @@ -666,8 +667,8 @@ void ivas_spar_md_dec_process( } #endif - /* SPAR to DirAC and DirAC to SPAR conversion */ - if ( st_ivas->sba_mode == SBA_MODE_SPAR ) + /* SPAR to DirAC and DirAC to SPAR conversion */ // VE2DB: -> "DirAC to SPAR conversion" only? + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) // VE2DB: this looks obsolete { ivas_spar_to_dirac( st_ivas, hMdDec, dtx_vad, num_bands_out ); @@ -691,7 +692,7 @@ void ivas_spar_md_dec_process( for ( j = 0; j < IVAS_SPAR_MAX_CH - IVAS_SPAR_MAX_DMX_CHS; j++ ) { - for ( int16_t k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ ) + for ( k = 0; k < IVAS_SPAR_MAX_DMX_CHS - 1; k++ ) { hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j][k] = hMdDec->spar_md.band_coeffs[b].C_re[j][k]; } @@ -736,6 +737,7 @@ void ivas_spar_md_dec_process( * * Smooth MD during no data frame during DTX *-----------------------------------------------------------------------------------------*/ + #ifdef SPAR_HOA_DBG /* NOTE: No changes here as DTX only operates below 160kbps */ #endif @@ -744,26 +746,23 @@ void ivas_spar_smooth_md_dtx( const int16_t num_bands_out /* i : number of output bands */ ) { - int16_t j, k, b; - int16_t dmx_ch; - ivas_spar_md_dec_state_t *pState = hMdDec; + int16_t j, k, b, dmx_ch; float ramp, tar, prev, new_val; - ramp = (float) pState->dtx_md_smoothing_cntr / IVAS_DEFAULT_DTX_CNG_RAMP; + ramp = (float) hMdDec->dtx_md_smoothing_cntr / IVAS_DEFAULT_DTX_CNG_RAMP; for ( b = 0; b < num_bands_out; b++ ) { - dmx_ch = pState->spar_md_cfg.num_dmx_chans_per_band[b]; + dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; for ( j = 1; j < FOA_CHANNELS; j++ ) { for ( k = dmx_ch; k < FOA_CHANNELS; k++ ) - { - prev = pState->spar_coeffs_prev.P_re[j][k][b]; - tar = pState->spar_coeffs_tar.P_re[j][k][b]; + prev = hMdDec->spar_coeffs_prev.P_re[j][k][b]; + tar = hMdDec->spar_coeffs_tar.P_re[j][k][b]; new_val = prev + ( ramp * ( tar - prev ) ); - pState->spar_coeffs.P_re[j][k][b] = new_val; + hMdDec->spar_coeffs.P_re[j][k][b] = new_val; } } @@ -771,10 +770,10 @@ void ivas_spar_smooth_md_dtx( { for ( k = 0; k < dmx_ch; k++ ) { - prev = pState->spar_coeffs_prev.C_re[j][k][b]; - tar = pState->spar_coeffs_tar.C_re[j][k][b]; + prev = hMdDec->spar_coeffs_prev.C_re[j][k][b]; + tar = hMdDec->spar_coeffs_tar.C_re[j][k][b]; new_val = prev + ( ramp * ( tar - prev ) ); - pState->spar_coeffs.C_re[j][k][b] = new_val; + hMdDec->spar_coeffs.C_re[j][k][b] = new_val; } } } @@ -784,14 +783,14 @@ void ivas_spar_smooth_md_dtx( { for ( b = 0; b < num_bands_out; b++ ) { - dmx_ch = pState->spar_md_cfg.num_dmx_chans_per_band[b]; + dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; for ( j = 1; j < FOA_CHANNELS; j++ ) { for ( k = dmx_ch; k < FOA_CHANNELS; k++ ) { - pState->spar_coeffs.P_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = pState->spar_coeffs.P_re[j][k][b]; + hMdDec->spar_coeffs.P_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re[j][k][b]; } } @@ -799,13 +798,13 @@ void ivas_spar_smooth_md_dtx( { for ( k = 0; k < dmx_ch; k++ ) { - pState->spar_coeffs.C_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = pState->spar_coeffs.C_re[j][k][b]; + hMdDec->spar_coeffs.C_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re[j][k][b]; } } } } - pState->dtx_md_smoothing_cntr = min( pState->dtx_md_smoothing_cntr + 1, IVAS_DEFAULT_DTX_CNG_RAMP ); + hMdDec->dtx_md_smoothing_cntr = min( hMdDec->dtx_md_smoothing_cntr + 1, IVAS_DEFAULT_DTX_CNG_RAMP ); return; } @@ -945,7 +944,7 @@ void ivas_spar_update_md_hist( *-----------------------------------------------------------------------------------------*/ static void ivas_get_spar_matrices( - ivas_spar_md_dec_state_t *pState, + ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t n_ts, const int16_t bw, @@ -953,16 +952,15 @@ static void ivas_get_spar_matrices( const int16_t nB, const int16_t sba_order ) { - int16_t numch_out, num_bands, dmx_ch; + int16_t numch_out, num_bands, dmx_ch, split_band; int16_t i, j, k, m, b, i_ts, active_w; const int16_t *order; float active_w_dm_fac, re; - int16_t split_band; numch_out = ivas_sba_get_nchan_metadata( sba_order ); num_bands = num_bands_out; - order = remix_order_set[pState->spar_md_cfg.remix_unmix_order]; + order = remix_order_set[hMdDec->spar_md_cfg.remix_unmix_order]; split_band = SPAR_DIRAC_SPLIT_START_BAND; if ( split_band >= IVAS_MAX_NUM_BANDS ) @@ -974,7 +972,7 @@ static void ivas_get_spar_matrices( { for ( b = 0; b < num_bands; b++ ) { - pState->mixer_mat_prev[0][i][j][b] = pState->mixer_mat[i][j][b]; + hMdDec->mixer_mat_prev[0][i][j][b] = hMdDec->mixer_mat[i][j][b]; } } } @@ -985,17 +983,17 @@ static void ivas_get_spar_matrices( { for (i = 0; i < IVAS_SPAR_MAX_CH - 1; i++) { - pState->spar_md.band_coeffs[b].pred_re[i] = (float)(i + 1)/10; + hMdDec->spar_md.band_coeffs[b].pred_re[i] = (float)(i + 1)/10; for (j = 0; j < IVAS_SPAR_MAX_CH - 1; j++) { - pState->spar_md.band_coeffs[b].C_re[i][j] = (float)(i + j * 20 + 1)/10; - pState->spar_md.band_coeffs[b].P_re[i][j] = (float)(i + j * 20 + 1)/10; + hMdDec->spar_md.band_coeffs[b].C_re[i][j] = (float)(i + j * 20 + 1)/10; + hMdDec->spar_md.band_coeffs[b].P_re[i][j] = (float)(i + j * 20 + 1)/10; } } }*/ #endif - active_w = pState->spar_md_cfg.active_w; + active_w = hMdDec->spar_md_cfg.active_w; active_w_dm_fac = ( dtx_vad == 0 ) ? IVAS_ACTIVEW_DM_F_SCALE_DTX : IVAS_ACTIVEW_DM_F_SCALE; for ( i_ts = 0; i_ts < n_ts; i_ts++ ) @@ -1004,8 +1002,8 @@ static void ivas_get_spar_matrices( { for ( j = 0; j < numch_out; j++ ) { - set_zero( &pState->spar_coeffs.C_re[i][j][i_ts * IVAS_MAX_NUM_BANDS], IVAS_MAX_NUM_BANDS ); - set_zero( &pState->spar_coeffs.P_re[i][j][i_ts * IVAS_MAX_NUM_BANDS], IVAS_MAX_NUM_BANDS ); + set_zero( &hMdDec->spar_coeffs.C_re[i][j][i_ts * IVAS_MAX_NUM_BANDS], IVAS_MAX_NUM_BANDS ); + set_zero( &hMdDec->spar_coeffs.P_re[i][j][i_ts * IVAS_MAX_NUM_BANDS], IVAS_MAX_NUM_BANDS ); } } @@ -1022,7 +1020,7 @@ static void ivas_get_spar_matrices( float tmp_C2_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; float tmp_dm_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH]; - dmx_ch = pState->spar_md_cfg.num_dmx_chans_per_band[bw * b]; + dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bw * b]; for ( j = 0; j < numch_out; j++ ) { @@ -1037,14 +1035,14 @@ static void ivas_get_spar_matrices( for ( j = 1; j < numch_out; j++ ) { - tmp_C1_re[j][0] = pState->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j - 1]; + tmp_C1_re[j][0] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j - 1]; } if ( active_w == 1 ) { for ( j = 1; j < numch_out; j++ ) { - tmp_C2_re[0][j] = active_w_dm_fac * -pState->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j - 1]; + tmp_C2_re[0][j] = active_w_dm_fac * -hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].pred_re[j - 1]; } IVAS_RMULT_FLOAT( tmp_C2_re[0][1], tmp_C1_re[1][0], re ); @@ -1068,9 +1066,9 @@ static void ivas_get_spar_matrices( tmp_dm_re[3][0] = tmp_C1_re[3][0]; - if ( pState->spar_md_cfg.remix_unmix_order != 3 ) + if ( hMdDec->spar_md_cfg.remix_unmix_order != 3 ) { - ivas_mat_col_rearrange( tmp_dm_re, order, i_ts, pState->mixer_mat, b, numch_out ); + ivas_mat_col_rearrange( tmp_dm_re, order, i_ts, hMdDec->mixer_mat, b, numch_out ); } else { @@ -1078,24 +1076,24 @@ static void ivas_get_spar_matrices( for ( i = 0; i < FOA_CHANNELS; i++ ) { /* row 0 */ - pState->mixer_mat[i][0][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][0]; + hMdDec->mixer_mat[i][0][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][0]; /* row 1 */ - pState->mixer_mat[i][1][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][1]; + hMdDec->mixer_mat[i][1][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][1]; /* row 3 */ - pState->mixer_mat[i][2][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][1]; + hMdDec->mixer_mat[i][2][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][1]; /* row 4 */ - pState->mixer_mat[i][3][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][2]; + hMdDec->mixer_mat[i][3][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_dm_re[i][2]; } } } else { - if ( pState->spar_md_cfg.remix_unmix_order != 3 ) + if ( hMdDec->spar_md_cfg.remix_unmix_order != 3 ) { - ivas_mat_col_rearrange( tmp_C1_re, order, i_ts, pState->mixer_mat, b, numch_out ); + ivas_mat_col_rearrange( tmp_C1_re, order, i_ts, hMdDec->mixer_mat, b, numch_out ); } else { @@ -1103,16 +1101,16 @@ static void ivas_get_spar_matrices( for ( i = 0; i < FOA_CHANNELS; i++ ) { /* row 0 */ - pState->mixer_mat[i][0][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][0]; + hMdDec->mixer_mat[i][0][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][0]; /* row 1 */ - pState->mixer_mat[i][1][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][1]; + hMdDec->mixer_mat[i][1][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][1]; /* row 3 */ - pState->mixer_mat[i][2][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][1]; + hMdDec->mixer_mat[i][2][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][1]; /* row 4 */ - pState->mixer_mat[i][3][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][2]; + hMdDec->mixer_mat[i][3][b + i_ts * IVAS_MAX_NUM_BANDS] = tmp_C1_re[i][2]; } } } @@ -1142,7 +1140,7 @@ static void ivas_get_spar_matrices( { for ( k = 1; k < dmx_ch; k++ ) { - tmpC_re[j][k] = pState->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j - dmx_ch][k - 1]; + tmpC_re[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].C_re[j - dmx_ch][k - 1]; } } #ifdef SPAR_HOA_DBG @@ -1161,7 +1159,7 @@ static void ivas_get_spar_matrices( { for (k = 0; k < numch_out; k++) { - fprintf(stdout, "%f, ", pState->mixer_mat[j][k][0][b]); + fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); } fprintf(stdout, "\n"); @@ -1173,7 +1171,7 @@ static void ivas_get_spar_matrices( { if ( ( j - dmx_ch ) == ( k - dmx_ch ) ) { - tmpP_re[j][k] = pState->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[k - dmx_ch]; + tmpP_re[j][k] = hMdDec->spar_md.band_coeffs[b + i_ts * IVAS_MAX_NUM_BANDS].P_re[k - dmx_ch]; } else { @@ -1199,7 +1197,7 @@ static void ivas_get_spar_matrices( { for (k = 0; k < numch_out; k++) { - fprintf(stdout, "%f, ", pState->mixer_mat[j][k][0][b]); + fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); } fprintf(stdout, "\n"); @@ -1213,8 +1211,8 @@ static void ivas_get_spar_matrices( { for ( m = 0; m < numch_out; m++ ) { - IVAS_RMULT_FLOAT( pState->mixer_mat[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpP_re[m][k], re ); - pState->spar_coeffs.P_re[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] += re; + IVAS_RMULT_FLOAT( hMdDec->mixer_mat[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpP_re[m][k], re ); + hMdDec->spar_coeffs.P_re[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] += re; } } } @@ -1225,8 +1223,8 @@ static void ivas_get_spar_matrices( { for ( m = 0; m < numch_out; m++ ) { - IVAS_RMULT_FLOAT( pState->mixer_mat[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpC_re[m][k], re ); - pState->spar_coeffs.C_re[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] += re; + IVAS_RMULT_FLOAT( hMdDec->mixer_mat[j][m][b + i_ts * IVAS_MAX_NUM_BANDS], tmpC_re[m][k], re ); + hMdDec->spar_coeffs.C_re[j][k][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] += re; } } } @@ -1236,14 +1234,14 @@ static void ivas_get_spar_matrices( { for (k = 0; k < dmx_ch; k++) { - fprintf(stdout, "%f, ", pState->spar_coeffs.C_re[j][k][b]); + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); } fprintf(stdout, "\n"); }*/ #endif - pState->spar_coeffs.C_re[0][0][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] = - max( 0, pState->spar_coeffs.C_re[0][0][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] ); + hMdDec->spar_coeffs.C_re[0][0][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] = + max( 0, hMdDec->spar_coeffs.C_re[0][0][( b * bw ) + i_ts * IVAS_MAX_NUM_BANDS] ); } } #ifdef SPAR_HOA_DBG @@ -1254,7 +1252,7 @@ static void ivas_get_spar_matrices( { for (k = 0; k < numch_out; k++) { - fprintf(stdout, "%f, ", pState->spar_coeffs.C_re[j][k][b]); + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); } fprintf(stdout, "\n"); @@ -1265,7 +1263,7 @@ static void ivas_get_spar_matrices( { for (k = 0; k < numch_out; k++) { - fprintf(stdout, "%f, ", pState->spar_coeffs.P_re[j][k][b]); + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.P_re[j][k][b]); } fprintf(stdout, "\n"); @@ -1278,12 +1276,12 @@ static void ivas_get_spar_matrices( { for ( b = 0; b < num_bands_out; b = b + bw ) { - dmx_ch = pState->spar_md_cfg.num_dmx_chans_per_band[b]; + dmx_ch = hMdDec->spar_md_cfg.num_dmx_chans_per_band[b]; for ( j = 0; j < numch_out; j++ ) { for ( k = dmx_ch; k < numch_out; k++ ) { - pState->spar_coeffs.P_re[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = pState->spar_coeffs.P_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS]; + hMdDec->spar_coeffs.P_re[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS]; } } @@ -1291,7 +1289,7 @@ static void ivas_get_spar_matrices( { for ( k = 0; k < dmx_ch; k++ ) { - pState->spar_coeffs.C_re[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = pState->spar_coeffs.C_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS]; + hMdDec->spar_coeffs.C_re[j][k][( b + 1 ) + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re[j][k][b + i_ts * IVAS_MAX_NUM_BANDS]; } } } @@ -1345,14 +1343,14 @@ void ivas_spar_dec_gen_umx_mat( const int16_t bfi /* i : bad frame indicator */ ) { - int16_t i, j, b, i_ts; - int16_t fb_ducking_flag = 0; - int16_t num_out_ch = hMdDec->spar_md_cfg.num_umx_chs; - ivas_spar_md_dec_state_t *pState = hMdDec; + int16_t i, j, b, i_ts, num_out_ch; + int16_t fb_ducking_flag = 0; // VE2DB: always 0 - can it be removed? + + num_out_ch = hMdDec->spar_md_cfg.num_umx_chs; for ( i_ts = 0; i_ts < MAX_PARAM_SPATIAL_SUBFRAMES; i_ts++ ) { - if ( pState->td_decorr_flag == 1 ) + if ( hMdDec->td_decorr_flag == 1 ) { for ( i = 0; i < num_out_ch; i++ ) { @@ -1360,7 +1358,7 @@ void ivas_spar_dec_gen_umx_mat( { for ( b = 0; b < num_bands_out; b++ ) { - pState->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = pState->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS]; + hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS]; } } } @@ -1371,7 +1369,7 @@ void ivas_spar_dec_gen_umx_mat( { for ( b = 0; b < num_bands_out; b++ ) { - pState->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = pState->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS]; + hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS]; } } } @@ -1389,7 +1387,7 @@ void ivas_spar_dec_gen_umx_mat( { for ( b = 0; b < num_bands_out; b++ ) { - pState->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = pState->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS]; + hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS]; } } } @@ -1404,7 +1402,7 @@ void ivas_spar_dec_gen_umx_mat( { for ( j = 0; j < num_out_ch; j++ ) { - fprintf( stdout, "%.2f,\t", pState->mixer_mat[i][j][0][b] ); + fprintf( stdout, "%.2f,\t", hMdDec->mixer_mat[i][j][0][b] ); } fprintf( stdout, "\n" ); } @@ -1412,7 +1410,7 @@ void ivas_spar_dec_gen_umx_mat( }*/ #endif - ivas_spar_dec_compute_ramp_down_post_matrix( pState, num_bands_out, bfi ); + ivas_spar_dec_compute_ramp_down_post_matrix( hMdDec, num_bands_out, bfi ); return; } @@ -1421,7 +1419,7 @@ void ivas_spar_dec_gen_umx_mat( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_dec_parse_md_bs() * - * Parses SPAR MD bitstream + * Parse SPAR MD bitstream *-----------------------------------------------------------------------------------------*/ static void ivas_spar_dec_parse_md_bs( @@ -1437,7 +1435,6 @@ static void ivas_spar_dec_parse_md_bs( int16_t i, j, k, num_bands; uint16_t qsi; ivas_quant_strat_t qs; - ivas_spar_md_dec_state_t *pState = hMdDec; int16_t strat, freq_diff, no_ec; int16_t do_diff[IVAS_MAX_NUM_BANDS]; int16_t planarCP = 0; @@ -1445,13 +1442,13 @@ static void ivas_spar_dec_parse_md_bs( *dtx_vad = 1; *bands_bw = 1; qsi = 0; - num_bands = pState->spar_md.num_bands; + num_bands = hMdDec->spar_md.num_bands; - if ( pState->spar_md_cfg.gen_bs == 1 ) + if ( hMdDec->spar_md_cfg.gen_bs == 1 ) { if ( ivas_total_brate > IVAS_SID_5k ) { - if ( pState->spar_md_cfg.quant_strat_bits > 0 ) + if ( hMdDec->spar_md_cfg.quant_strat_bits > 0 ) { if ( ivas_total_brate >= BRATE_SPAR_Q_STRAT ) { @@ -1467,11 +1464,11 @@ static void ivas_spar_dec_parse_md_bs( if ( sba_inactive_mode == 1 ) { *dtx_vad = 0; - qsi = pState->spar_md_cfg.quant_strat_bits + 1; + qsi = hMdDec->spar_md_cfg.quant_strat_bits + 1; } else { - qsi = get_next_indice( st0, pState->spar_md_cfg.quant_strat_bits ); + qsi = get_next_indice( st0, hMdDec->spar_md_cfg.quant_strat_bits ); } } } @@ -1496,10 +1493,10 @@ static void ivas_spar_dec_parse_md_bs( { for ( j = 0; j < IVAS_SPAR_MAX_CH - 1; j++ ) { - pState->spar_md.band_coeffs[i].pred_re[j] = 0; - pState->spar_md.band_coeffs[i].P_re[j] = 0; + hMdDec->spar_md.band_coeffs[i].pred_re[j] = 0; + hMdDec->spar_md.band_coeffs[i].P_re[j] = 0; } - pState->valid_bands[i] = 1; + hMdDec->valid_bands[i] = 1; } for ( i = 0; i < num_bands; i++ ) { @@ -1507,31 +1504,31 @@ static void ivas_spar_dec_parse_md_bs( { for ( k = 0; k < ( IVAS_SPAR_MAX_DMX_CHS - 1 ); k++ ) { - pState->spar_md.band_coeffs[i].C_re[j][k] = 0; + hMdDec->spar_md.band_coeffs[i].C_re[j][k] = 0; } } } - ivas_parse_parameter_bitstream_dtx( &pState->spar_md, st0, *bands_bw, *nB, - pState->spar_md_cfg.num_dmx_chans_per_band, pState->spar_md_cfg.num_decorr_per_band ); + ivas_parse_parameter_bitstream_dtx( &hMdDec->spar_md, st0, *bands_bw, *nB, + hMdDec->spar_md_cfg.num_dmx_chans_per_band, hMdDec->spar_md_cfg.num_decorr_per_band ); { int16_t ndec, b, idx; for ( i = *nB - 1; i >= 0; i-- ) { - ndec = pState->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; + ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; for ( b = *bands_bw - 1; b >= 0; b-- ) { idx = i * *bands_bw + b; for ( j = 0; j < FOA_CHANNELS - 1; j++ ) { - pState->spar_md.band_coeffs[idx].pred_re[j] = pState->spar_md.band_coeffs[i].pred_re[j]; + hMdDec->spar_md.band_coeffs[idx].pred_re[j] = hMdDec->spar_md.band_coeffs[i].pred_re[j]; } for ( j = 0; j < ndec; j++ ) { - pState->spar_md.band_coeffs[idx].P_re[j] = pState->spar_md.band_coeffs[i].P_re[j]; + hMdDec->spar_md.band_coeffs[idx].P_re[j] = hMdDec->spar_md.band_coeffs[i].P_re[j]; } - pState->valid_bands[idx] = 1; + hMdDec->valid_bands[idx] = 1; } } *nB = num_bands; @@ -1541,7 +1538,7 @@ static void ivas_spar_dec_parse_md_bs( return; } - qs = pState->spar_md_cfg.quant_strat[qsi]; + qs = hMdDec->spar_md_cfg.quant_strat[qsi]; if ( ( qsi == 2 ) && ( use_planar_coeff ) ) { planarCP = 1; @@ -1585,20 +1582,20 @@ static void ivas_spar_dec_parse_md_bs( do_diff[i] = ( ( ( i + 1 ) & 3 ) != strat - 4 ); } - ivas_map_prior_coeffs_quant( &pState->spar_md_prev, &pState->spar_md_cfg, qsi, *nB ); + ivas_map_prior_coeffs_quant( &hMdDec->spar_md_prev, &hMdDec->spar_md_cfg, qsi, *nB ); } #ifdef SPAR_HOA_DBG fprintf( stdout, "\n\n no_ec = %d, strat = %d\n", no_ec, strat ); #endif - pState->spar_md_cfg.prev_quant_idx = qsi; + hMdDec->spar_md_cfg.prev_quant_idx = qsi; if ( no_ec == 0 ) { - ivas_decode_arith_bs( pState, st0, qsi, *nB, *bands_bw, do_diff, freq_diff, planarCP ); + ivas_decode_arith_bs( hMdDec, st0, qsi, *nB, *bands_bw, do_diff, freq_diff, planarCP ); } else { - ivas_decode_huffman_bs( pState, st0, qsi, *nB, *bands_bw, planarCP ); + ivas_decode_huffman_bs( hMdDec, st0, qsi, *nB, *bands_bw, planarCP ); } for ( i = 0; i < *nB; i++ ) @@ -1606,8 +1603,8 @@ static void ivas_spar_dec_parse_md_bs( int16_t ii, jj; int16_t *index_scratch[IVAS_SPAR_P_LOWERTRI]; float *quant_scratch[IVAS_SPAR_P_LOWERTRI]; - int16_t ndec = pState->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; - int16_t ndm = pState->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i]; + int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; + int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i]; int16_t **index = (int16_t **) &index_scratch[0]; float **quant = (float **) &quant_scratch[0]; float coeff_decd[IVAS_SPAR_MAX_CH - 1]; @@ -1619,26 +1616,26 @@ static void ivas_spar_dec_parse_md_bs( for ( j = 0; j < ndm + ndec - 1; j++ ) { - pred_index_re[j] = pState->spar_md.band_coeffs_idx[i].pred_index_re[j]; + pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j]; } for ( j = 0; j < ndec * ( ndm - 1 ); j++ ) { - drct_index_re[j] = pState->spar_md.band_coeffs_idx[i].drct_index_re[j]; + drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j]; } for ( j = 0; j < ndec; j++ ) { - decd_index_re[j] = pState->spar_md.band_coeffs_idx[i].decd_index_re[j]; + decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j]; } index[0] = &pred_index_re[0]; - quant[0] = &pState->spar_md.band_coeffs[i].pred_re[0]; + quant[0] = &hMdDec->spar_md.band_coeffs[i].pred_re[0]; ivas_deindex_real_index( index, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, quant, 1, ndm + ndec - 1 ); for ( ii = 0; ii < ndec; ii++ ) { for ( jj = 0; jj < ndm - 1; jj++ ) { - pState->spar_md.band_coeffs[i].C_re[ii][jj] = 0; + hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = 0; } } j = 0; @@ -1647,7 +1644,7 @@ static void ivas_spar_dec_parse_md_bs( for ( jj = 0; jj < ndm - 1; jj++ ) { index[j] = &drct_index_re[j]; - quant[j] = &pState->spar_md.band_coeffs[i].C_re[ii][jj]; + quant[j] = &hMdDec->spar_md.band_coeffs[i].C_re[ii][jj]; j++; } } @@ -1664,38 +1661,38 @@ static void ivas_spar_dec_parse_md_bs( /* Store prior coefficient indices */ for ( j = 0; j < ndm + ndec - 1; j++ ) { - pState->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = pred_index_re[j]; + hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = pred_index_re[j]; } for ( j = 0; j < ndec * ( ndm - 1 ); j++ ) { - pState->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = drct_index_re[j]; + hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = drct_index_re[j]; } for ( j = 0; j < ndec; j++ ) { - pState->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = decd_index_re[j]; + hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = decd_index_re[j]; } for ( k = 0; k < ndec; k++ ) { - pState->spar_md.band_coeffs[i].P_re[k] = 0; + hMdDec->spar_md.band_coeffs[i].P_re[k] = 0; } for ( j = 0; j < ndec; j++ ) { /* Don't bother adding in the decx parameters */ - pState->spar_md.band_coeffs[i].P_re[j] = coeff_decd[j]; + hMdDec->spar_md.band_coeffs[i].P_re[j] = coeff_decd[j]; } - pState->valid_bands[i] |= ( do_diff[i] == 0 ) ? 1 : 0; + hMdDec->valid_bands[i] |= ( do_diff[i] == 0 ) ? 1 : 0; } } else { - *dtx_vad = pState->spar_md.dtx_vad; + *dtx_vad = hMdDec->spar_md.dtx_vad; *nB = num_bands; *bands_bw = num_bands / *nB; for ( i = 0; i < *nB; i++ ) { - pState->valid_bands[i] = 1; + hMdDec->valid_bands[i] = 1; } } #ifdef SPAR_HOA_DBG @@ -1705,15 +1702,15 @@ static void ivas_spar_dec_parse_md_bs( { for ( b = 0; b < *nB; b++ ) { - int16_t ndec = pState->spar_md_cfg.num_decorr_per_band[(*bands_bw) * b]; - int16_t ndm = pState->spar_md_cfg.num_dmx_chans_per_band[(*bands_bw) * b]; + int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[(*bands_bw) * b]; + int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[(*bands_bw) * b]; fprintf(stdout, "\n\nMETADATA PR: band %d, qsi %d\n\n", b, qsi); for (i = 0; i < ndm + ndec - 1; i++) { fprintf(stdout, "i: %d -- %f\t %d\t %d\n", i, - pState->spar_md.band_coeffs[b].pred_re[i], - pState->spar_md_prev.band_coeffs_idx[b].pred_index_re[i], - pState->spar_md.band_coeffs_idx[b].pred_index_re[i]); + hMdDec->spar_md.band_coeffs[b].pred_re[i], + hMdDec->spar_md_prev.band_coeffs_idx[b].pred_index_re[i], + hMdDec->spar_md.band_coeffs_idx[b].pred_index_re[i]); } fprintf(stdout, "\n\n METADATA C: band %d\n\n", b); k = 0; @@ -1722,9 +1719,9 @@ static void ivas_spar_dec_parse_md_bs( for (j = 0; j < (ndm - 1); j++) { fprintf(stdout, "i: %d -- %f\t %d\t %d\n", i, - pState->spar_md.band_coeffs[b].C_re[i][j], - pState->spar_md_prev.band_coeffs_idx[b].drct_index_re[k], - pState->spar_md.band_coeffs_idx[b].drct_index_re[k]); + hMdDec->spar_md.band_coeffs[b].C_re[i][j], + hMdDec->spar_md_prev.band_coeffs_idx[b].drct_index_re[k], + hMdDec->spar_md.band_coeffs_idx[b].drct_index_re[k]); k++; } } @@ -1732,17 +1729,17 @@ static void ivas_spar_dec_parse_md_bs( for (i = 0; i < ndec; i++) { fprintf(stdout, "i: %d -- %f\t %d\t %d\n", i, - pState->spar_md.band_coeffs[b].P_re[i][i], - pState->spar_md_prev.band_coeffs_idx[b].decd_index_re[i], - pState->spar_md.band_coeffs_idx[b].decd_index_re[i]); + hMdDec->spar_md.band_coeffs[b].P_re[i][i], + hMdDec->spar_md_prev.band_coeffs_idx[b].decd_index_re[i], + hMdDec->spar_md.band_coeffs_idx[b].decd_index_re[i]); } fprintf(stdout, "\n\n"); - int16_t ndec = pState->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * b]; - int16_t ndm = pState->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * b]; + int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * b]; + int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * b]; fprintf( stdout, "\n\n Metadata PR (15x1), C(15x15), P(15x15): band %d\n", b ); for ( i = 0; i < ndm + ndec - 1; i++ ) { - fprintf( stdout, "i: %d -- %.2f\t|\t", i, pState->spar_md.band_coeffs[b].pred_re[i] ); + fprintf( stdout, "i: %d -- %.2f\t|\t", i, hMdDec->spar_md.band_coeffs[b].pred_re[i] ); if ( i < ndec ) { if ( keep_planar[i] == 1 ) @@ -1755,12 +1752,12 @@ static void ivas_spar_dec_parse_md_bs( } for ( j = 0; j < ndm - 1; j++ ) { - fprintf( stdout, "%.2f\t", pState->spar_md.band_coeffs[b].C_re[i][j] ); + fprintf( stdout, "%.2f\t", hMdDec->spar_md.band_coeffs[b].C_re[i][j] ); } fprintf( stdout, "|\t" ); for ( j = 0; j < ndec; j++ ) { - fprintf( stdout, "%.2f\t", pState->spar_md.band_coeffs[b].P_re[i][j] ); + fprintf( stdout, "%.2f\t", hMdDec->spar_md.band_coeffs[b].P_re[i][j] ); } } fprintf( stdout, "\n" ); @@ -1777,11 +1774,11 @@ static void ivas_spar_dec_parse_md_bs( /*-----------------------------------------------------------------------------------------* * Function ivas_decode_arith_bs() * - * decode bitstream with arith decoder + * Decode bitstream with arith decoder *-----------------------------------------------------------------------------------------*/ static void ivas_decode_arith_bs( - ivas_spar_md_dec_state_t *pState, + ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ const uint16_t qsi, const int16_t nB, @@ -1801,8 +1798,8 @@ static void ivas_decode_arith_bs( for ( i = 0; i < nB; i++ ) { - ndm = pState->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; - ndec = pState->spar_md_cfg.num_decorr_per_band[bands_bw * i]; + ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; + ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i]; pred_cell_dims[i].dim1 = ndm + ndec - 1; pred_cell_dims[i].dim2 = 1; @@ -1825,17 +1822,17 @@ static void ivas_decode_arith_bs( if ( any_diff == 1 ) { - ivas_copy_band_coeffs_idx_to_arr( pState->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF, planarCP ); + ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, pred_cell_dims, PRED_COEFF, planarCP ); } - ivas_arith_decode_cmplx_cell_array( &pState->arith_coeffs.pred_arith_re[qsi], &pState->arith_coeffs.pred_arith_re_diff[qsi], + ivas_arith_decode_cmplx_cell_array( &hMdDec->arith_coeffs.pred_arith_re[qsi], &hMdDec->arith_coeffs.pred_arith_re_diff[qsi], st0, pred_cell_dims, pDo_diff, nB, symbol_arr_re, symbol_arr_old_re ); - ivas_fill_band_coeffs_idx( pState->spar_md.band_coeffs_idx, nB, symbol_arr_re, pred_cell_dims, PRED_COEFF, planarCP ); + ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, pred_cell_dims, PRED_COEFF, planarCP ); if ( any_diff == 1 ) { - ivas_copy_band_coeffs_idx_to_arr( pState->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, drct_cell_dims, DRCT_COEFF, planarCP ); + ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, drct_cell_dims, DRCT_COEFF, planarCP ); } if ( planarCP ) @@ -1846,14 +1843,14 @@ static void ivas_decode_arith_bs( } } - ivas_arith_decode_cmplx_cell_array( &pState->arith_coeffs.drct_arith_re[qsi], &pState->arith_coeffs.drct_arith_re_diff[qsi], + ivas_arith_decode_cmplx_cell_array( &hMdDec->arith_coeffs.drct_arith_re[qsi], &hMdDec->arith_coeffs.drct_arith_re_diff[qsi], st0, drct_cell_dims, pDo_diff, nB, symbol_arr_re, symbol_arr_old_re ); - ivas_fill_band_coeffs_idx( pState->spar_md.band_coeffs_idx, nB, symbol_arr_re, drct_cell_dims, DRCT_COEFF, planarCP ); + ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, drct_cell_dims, DRCT_COEFF, planarCP ); if ( any_diff == 1 ) { - ivas_copy_band_coeffs_idx_to_arr( pState->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decd_cell_dims, DECD_COEFF, planarCP ); + ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decd_cell_dims, DECD_COEFF, planarCP ); } if ( planarCP ) @@ -1864,27 +1861,27 @@ static void ivas_decode_arith_bs( } } - ivas_arith_decode_cmplx_cell_array( &pState->arith_coeffs.decd_arith_re[qsi], &pState->arith_coeffs.decd_arith_re_diff[qsi], + ivas_arith_decode_cmplx_cell_array( &hMdDec->arith_coeffs.decd_arith_re[qsi], &hMdDec->arith_coeffs.decd_arith_re_diff[qsi], st0, decd_cell_dims, pDo_diff, nB, symbol_arr_re, symbol_arr_old_re ); - ivas_fill_band_coeffs_idx( pState->spar_md.band_coeffs_idx, nB, symbol_arr_re, decd_cell_dims, DECD_COEFF, planarCP ); + ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, decd_cell_dims, DECD_COEFF, planarCP ); if ( any_diff == 1 ) { - ivas_copy_band_coeffs_idx_to_arr( pState->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decx_cell_dims, DECX_COEFF, planarCP ); + ivas_copy_band_coeffs_idx_to_arr( hMdDec->spar_md_prev.band_coeffs_idx_mapped, nB, symbol_arr_old_re, decx_cell_dims, DECX_COEFF, planarCP ); } - ivas_fill_band_coeffs_idx( pState->spar_md.band_coeffs_idx, nB, symbol_arr_re, decx_cell_dims, DECX_COEFF, planarCP ); + ivas_fill_band_coeffs_idx( hMdDec->spar_md.band_coeffs_idx, nB, symbol_arr_re, decx_cell_dims, DECX_COEFF, planarCP ); if ( freq_diff == 1 ) { #ifdef SPAR_HOA_DBG /* NOTE: This is currently unused code, and SPAR_HOA changes have not been made here. */ #endif - ivas_get_band_idx_from_differential( &pState->spar_md, pState->spar_md_cfg.quant_strat->PR.q_levels, 0, nB, PRED_COEFF ); - ivas_get_band_idx_from_differential( &pState->spar_md, pState->spar_md_cfg.quant_strat->C.q_levels, 0, nB, DRCT_COEFF ); - ivas_get_band_idx_from_differential( &pState->spar_md, pState->spar_md_cfg.quant_strat->P_r.q_levels, 1, nB, DECD_COEFF ); - ivas_get_band_idx_from_differential( &pState->spar_md, pState->spar_md_cfg.quant_strat->P_c.q_levels, 0, nB, DECX_COEFF ); + ivas_get_band_idx_from_differential( &hMdDec->spar_md, hMdDec->spar_md_cfg.quant_strat->PR.q_levels, 0, nB, PRED_COEFF ); + ivas_get_band_idx_from_differential( &hMdDec->spar_md, hMdDec->spar_md_cfg.quant_strat->C.q_levels, 0, nB, DRCT_COEFF ); + ivas_get_band_idx_from_differential( &hMdDec->spar_md, hMdDec->spar_md_cfg.quant_strat->P_r.q_levels, 1, nB, DECD_COEFF ); + ivas_get_band_idx_from_differential( &hMdDec->spar_md, hMdDec->spar_md_cfg.quant_strat->P_c.q_levels, 0, nB, DECX_COEFF ); } return; @@ -1896,6 +1893,7 @@ static void ivas_decode_arith_bs( * * *-----------------------------------------------------------------------------------------*/ + #ifdef SPAR_HOA_DBG /* NOTE: No changes here as frequency differential coding is unused. */ #endif @@ -2055,11 +2053,11 @@ static void ivas_fill_band_coeffs_idx( /*-----------------------------------------------------------------------------------------* * Function ivas_decode_huffman_bs() * - * decode bitstream with huffman decoder + * Decode bitstream with huffman decoder *-----------------------------------------------------------------------------------------*/ static void ivas_decode_huffman_bs( - ivas_spar_md_dec_state_t *pState, + ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st0, /* i/o: decoder state structure - for bitstream handling*/ const uint16_t qsi, const int16_t nB, @@ -2073,8 +2071,8 @@ static void ivas_decode_huffman_bs( int16_t ndm, ndec; int16_t pred_dim, drct_dim, decd_dim; - ndm = pState->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; - ndec = pState->spar_md_cfg.num_decorr_per_band[bands_bw * i]; + ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[bands_bw * i]; + ndec = hMdDec->spar_md_cfg.num_decorr_per_band[bands_bw * i]; pred_dim = ndec + ndm - 1; drct_dim = ndec * ( ndm - 1 ); @@ -2082,20 +2080,20 @@ static void ivas_decode_huffman_bs( for ( j = 0; j < pred_dim; j++ ) { - ivas_huffman_decode( &pState->huff_coeffs.pred_huff_re[qsi], st0, - &pState->spar_md.band_coeffs_idx[i].pred_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.pred_huff_re[qsi], st0, + &hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j] ); } for ( j = 0; j < drct_dim; j++ ) { if ( planarCP && !keep_planar[(int16_t) floor( j / ( ndm - 1 ) )] ) { - pState->spar_md.band_coeffs_idx[i].drct_index_re[j] = 0; + hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] = 0; } else { - ivas_huffman_decode( &pState->huff_coeffs.drct_huff_re[qsi], st0, - &pState->spar_md.band_coeffs_idx[i].drct_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.drct_huff_re[qsi], st0, + &hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j] ); } } @@ -2103,12 +2101,12 @@ static void ivas_decode_huffman_bs( { if ( planarCP && !keep_planar[j] ) { - pState->spar_md.band_coeffs_idx[i].decd_index_re[j] = 0; + hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] = 0; } else { - ivas_huffman_decode( &pState->huff_coeffs.decd_huff_re[qsi], st0, - &pState->spar_md.band_coeffs_idx[i].decd_index_re[j] ); + ivas_huffman_decode( &hMdDec->huff_coeffs.decd_huff_re[qsi], st0, + &hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j] ); } } } @@ -2120,14 +2118,14 @@ static void ivas_decode_huffman_bs( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_md_fill_invalid_bands() * - * fill invalid bands in interpolation/extrapolation of valid bands + * Fill invalid bands in interpolation/extrapolation of valid bands * when PLC is to be done with partial time differential coding *-----------------------------------------------------------------------------------------*/ static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coeffs, ivas_spar_dec_matrices_t *pSpar_coeffs_prev, - int16_t *valid_bands, + const int16_t *valid_bands, int16_t *base_band_age, const int16_t num_bands, const int16_t sba_order /* i : SBA order */ @@ -2244,42 +2242,41 @@ static void ivas_spar_md_fill_invalid_bands( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_dec_compute_ramp_down_post_matrix() * -* ivas_spar_dec_compute_ramp_down_post_matrix - +* *-----------------------------------------------------------------------------------------*/ static void ivas_spar_dec_compute_ramp_down_post_matrix( - ivas_spar_md_dec_state_t *pState, + ivas_spar_md_dec_state_t *hMdDec, const int16_t num_bands_out, const int16_t bfi ) { int16_t num_in_ch, num_out_ch, i, j, b; - num_in_ch = pState->spar_md_cfg.num_umx_chs; - num_out_ch = pState->spar_md_cfg.num_umx_chs; + num_in_ch = hMdDec->spar_md_cfg.num_umx_chs; + num_out_ch = hMdDec->spar_md_cfg.num_umx_chs; if ( bfi == 0 ) { - pState->spar_plc_num_lost_frames = 0; + hMdDec->spar_plc_num_lost_frames = 0; } else { - if ( pState->td_decorr_flag == 0 ) + if ( hMdDec->td_decorr_flag == 0 ) { assert( 0 ); } - pState->spar_plc_num_lost_frames += 1; - pState->spar_plc_num_lost_frames = min( pState->spar_plc_num_lost_frames, 100 ); + hMdDec->spar_plc_num_lost_frames += 1; + hMdDec->spar_plc_num_lost_frames = min( hMdDec->spar_plc_num_lost_frames, 100 ); - if ( pState->spar_plc_num_lost_frames > ivas_spar_dec_plc_num_frames_keep ) + if ( hMdDec->spar_plc_num_lost_frames > ivas_spar_dec_plc_num_frames_keep ) { int16_t num_fade_frames; int16_t gain_dB; float gain; float post_matrix[IVAS_SPAR_MAX_CH]; - num_fade_frames = max( pState->spar_plc_num_lost_frames - ivas_spar_dec_plc_num_frames_keep, 0 ); + num_fade_frames = max( hMdDec->spar_plc_num_lost_frames - ivas_spar_dec_plc_num_frames_keep, 0 ); gain_dB = -min( num_fade_frames, ivas_spar_dec_plc_max_num_frames_ramp_down ) * ivas_spar_dec_plc_per_frame_ramp_down_gain_dB; gain = powf( 10, ( ( (float) gain_dB ) / 20 ) ); @@ -2298,7 +2295,7 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( { for ( b = 0; b < num_bands_out; b++ ) { - pState->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] *= post_matrix[i]; + hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] *= post_matrix[i]; } } } @@ -2313,7 +2310,7 @@ static void ivas_spar_dec_compute_ramp_down_post_matrix( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_unquant_dtx_indicies() * - * Unquantize spar md DYX indices + * Unquantize SPAR MD DYX indices *-----------------------------------------------------------------------------------------*/ #ifdef SPAR_HOA_DBG @@ -2494,7 +2491,7 @@ static void ivas_parse_parameter_bitstream_dtx( /*-----------------------------------------------------------------------------------------* * Function ivas_deindex_real_index() * - * deindex real index + * Deindex real index *-----------------------------------------------------------------------------------------*/ static ivas_error ivas_deindex_real_index( diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index a2c0e21dcb..c773491d41 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -253,7 +253,7 @@ typedef struct stereo_dec_cng int16_t xfade_length; /* number of frames to perform xfade */ int16_t nr_dft_frames; /* dft frame counter */ int16_t nr_corr_frames; /* correlation frame counter */ - int16_t nr_sid_frames; /* sid frame counter */ + int16_t nr_sid_frames; /* SID frame counter */ int16_t last_act_element_mode; /* Element mode of last active frame */ float olapBufferSynth22[FFTLEN]; /* overlap buffer for secondary channel CNA */ int16_t flag_cna_fade; /* flag enabling CNA fade out */ diff --git a/lib_enc/ivas_qmetadata_enc.c b/lib_enc/ivas_qmetadata_enc.c index f62b61e4ef..c36ac09b38 100644 --- a/lib_enc/ivas_qmetadata_enc.c +++ b/lib_enc/ivas_qmetadata_enc.c @@ -688,7 +688,7 @@ void ivas_qmetadata_enc_sid_encode( } else { - /* keep 13.2 and 16.4 sid bitrate as 4.4 kbps for now*/ + /* keep 13.2 and 16.4 SID bitrate as 4.4 kbps for now*/ metadata_sid_bits = ( IVAS_SID_4k4 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; } } diff --git a/lib_enc/ivas_spar_encoder.c b/lib_enc/ivas_spar_encoder.c index df17d47cfd..bb97dadbd1 100644 --- a/lib_enc/ivas_spar_encoder.c +++ b/lib_enc/ivas_spar_encoder.c @@ -538,7 +538,7 @@ static ivas_error ivas_spar_enc_process( set_zero( avg_dir, 3 ); energySum = 0.0f; - /*combine all dirac bands except the last one, handle last band separately, last band covers BW above WB*/ + /* combine all DirAC bands except the last one, handle last band separately, last band covers BW above WB */ for ( j = 0; j < orig_dirac_bands - 1; j++ ) { ivas_qmetadata_azimuth_elevation_to_direction_vector( hQMetaData->q_direction[0].band_data[j].azimuth[i], hQMetaData->q_direction[0].band_data[j].elevation[i], &dir[0] ); @@ -608,7 +608,7 @@ static ivas_error ivas_spar_enc_process( /* use just VAD function to get VAD flags */ dtx_vad = ( hEncoderConfig->Opt_DTX_ON == 1 ) ? front_vad_flag : 1; dtx_cov_flag = ( dtx_vad == 1 ) ? 0 : 1; - dtx_silence_mode = 0; + dtx_silence_mode = 0; // VE2DB: this variable is always 0 - please review or remove it bwidth = ivas_get_bw_idx_from_sample_rate( input_Fs ); bwidth = min( bwidth, hEncoderConfig->max_bwidth ); @@ -679,7 +679,7 @@ static ivas_error ivas_spar_enc_process( md_in_buf.dtx_vad = dtx_vad; ivas_spar_md_enc_process( hSpar->hMdEnc, hEncoderConfig, &md_in_buf, hMetaData, dtx_silence_mode, sba_order ); - if ( st_ivas->sba_mode == SBA_MODE_SPAR ) + if ( st_ivas->sba_mode == SBA_MODE_SPAR ) // VE2DB: this looks obsolete { float azi_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; float ele_dirac[IVAS_MAX_NUM_BANDS][MAX_PARAM_SPATIAL_SUBFRAMES]; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 485d98da5b..a63f3af172 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -72,11 +72,11 @@ static void ivas_band_mixer( float *cov_re[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH], static void ivas_get_band_differential_index( ivas_band_coeffs_ind_t *pBand_idx, const int16_t q_levels[2], const int16_t one_sided, const int16_t nB, const int16_t complex_cov, const int16_t dim, const ivas_coeffs_type_t coeff_type ); -static void ivas_get_huffman_coded_bs( ivas_spar_md_enc_state_t *pState, BSTR_ENC_HANDLE hMetaData, const int16_t nB, const int16_t qsi, const int16_t planarCP ); +static void ivas_get_huffman_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t nB, const int16_t qsi, const int16_t planarCP ); -static void ivas_get_arith_coded_bs( ivas_spar_md_enc_state_t *pState, BSTR_ENC_HANDLE hMetaData, const int16_t *pDo_diff, const int16_t bands_bw, const int16_t nB, const int16_t qsi, const int16_t planarCP ); +static void ivas_get_arith_coded_bs( ivas_spar_md_enc_state_t *hMdEnc, BSTR_ENC_HANDLE hMetaData, const int16_t *pDo_diff, const int16_t bands_bw, const int16_t nB, const int16_t qsi, const int16_t planarCP ); -static ivas_error ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *pState, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp ); +static ivas_error ivas_spar_set_enc_config( ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, const int16_t nchan_inp ); static void ivas_select_next_strat( ivas_strats_t prior_strat, ivas_strats_t cs[MAX_QUANT_STRATS], const int16_t dmx_switch, const int16_t dtx_vad ); @@ -84,7 +84,7 @@ static void ivas_store_prior_coeffs( ivas_spar_md_enc_state_t *hMdEnc, const int static void ivas_write_parameter_bitstream( ivas_spar_md_enc_state_t *hMdEnc, const int16_t nB, const int16_t bands_bw, BSTR_ENC_HANDLE hMetaData, const int32_t ivas_total_brate, const int16_t dtx_silence_mode, const int16_t strat, const int16_t qsi, const int16_t planarCP ); -static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *pState, const ENCODER_CONFIG_HANDLE hEncoderConfig, const int16_t sba_order ); +static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *hMdEnc, const ENCODER_CONFIG_HANDLE hEncoderConfig, const int16_t sba_order ); static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, float **ppValues, const int16_t ndm, int16_t **ppIndex, const int16_t dim1, float **ppQuant ); @@ -304,11 +304,11 @@ void ivas_spar_md_enc_close( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_md_enc_init() * - * Init call for md gen process + * SPAR MD encoder initialization *-----------------------------------------------------------------------------------------*/ static ivas_error ivas_spar_md_enc_init( - ivas_spar_md_enc_state_t *pState, /* o : MD encoder handle */ + 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 */ ) @@ -322,8 +322,8 @@ static ivas_error ivas_spar_md_enc_init( table_idx = ivas_get_spar_table_idx( hEncoderConfig->ivas_total_brate, sba_order, SPAR_CONFIG_BW, NULL, NULL ); - pState->spar_md_cfg.gen_bs = 1; - ivas_spar_set_bitrate_config( &pState->spar_md_cfg, table_idx, SPAR_DIRAC_SPLIT_START_BAND ); + hMdEnc->spar_md_cfg.gen_bs = 1; + ivas_spar_set_bitrate_config( &hMdEnc->spar_md_cfg, table_idx, SPAR_DIRAC_SPLIT_START_BAND ); /* get FB coefficients */ for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) @@ -331,39 +331,39 @@ static ivas_error ivas_spar_md_enc_init( pFC[i] = ivas_fb_fcs_12band_1ms[i] * hEncoderConfig->input_Fs * 0.5f; } - ivas_spar_set_enc_config( pState, pState->spar_md_cfg.max_freq_per_chan, pState->spar_md_cfg.nchan_transport, pFC, num_channels ); + ivas_spar_set_enc_config( hMdEnc, hMdEnc->spar_md_cfg.max_freq_per_chan, hMdEnc->spar_md_cfg.nchan_transport, pFC, num_channels ); /* - if(pState->spar_md_cfg.quant_strat[0].C.q_levels[0] == 0 || pState->spar_md_cfg.quant_strat[0].C.q_levels[1] == 0 - || pState->spar_md_cfg.quant_strat[0].PR.q_levels[0] == 0 || pState->spar_md_cfg.quant_strat[0].PR.q_levels[1] == 0 - || pState->spar_md_cfg.quant_strat[0].P_c.q_levels[0] == 0 || pState->spar_md_cfg.quant_strat[0].P_c.q_levels[1] == 0 - || pState->spar_md_cfg.quant_strat[0].P_r.q_levels[0] == 0 || pState->spar_md_cfg.quant_strat[0].P_r.q_levels[1] == 0) + if(hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[1] == 0 + || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[1] == 0 + || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[1] == 0 + || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[1] == 0) { - pState->spar_md_cfg.gen_bs = 0; + hMdEnc->spar_md_cfg.gen_bs = 0; } - else if(0 != pState->spar_md_cfg.gen_bs) + else if(0 != hMdEnc->spar_md_cfg.gen_bs) { - pState->spar_md_cfg.quant_strat_bits = ivas_get_bits_to_encode(MAX_QUANT_STRATS); + hMdEnc->spar_md_cfg.quant_strat_bits = ivas_get_bits_to_encode(MAX_QUANT_STRATS); } */ - if ( pState->spar_md_cfg.nchan_transport != 2 && ( ( pState->spar_md_cfg.remix_unmix_order == 1 ) || ( pState->spar_md_cfg.remix_unmix_order == 2 ) ) ) + if ( hMdEnc->spar_md_cfg.nchan_transport != 2 && ( ( hMdEnc->spar_md_cfg.remix_unmix_order == 1 ) || ( hMdEnc->spar_md_cfg.remix_unmix_order == 2 ) ) ) { return IVAS_ERR_INTERNAL; } - ivas_spar_arith_coeffs_com_init( &pState->arith_coeffs, &pState->spar_md_cfg, table_idx, ENC ); - ivas_spar_huff_coeffs_com_init( &pState->huff_coeffs, NULL, table_idx, ENC ); + ivas_spar_arith_coeffs_com_init( &hMdEnc->arith_coeffs, &hMdEnc->spar_md_cfg, table_idx, ENC ); + ivas_spar_huff_coeffs_com_init( &hMdEnc->huff_coeffs, NULL, table_idx, ENC ); if ( hEncoderConfig->Opt_DTX_ON == 1 ) { /* DTX quant init */ - PR_minmax[0] = pState->spar_md_cfg.quant_strat[0].PR.min; - PR_minmax[1] = pState->spar_md_cfg.quant_strat[0].PR.max; - ivas_spar_quant_dtx_init( &pState->spar_md, PR_minmax ); + PR_minmax[0] = hMdEnc->spar_md_cfg.quant_strat[0].PR.min; + PR_minmax[1] = hMdEnc->spar_md_cfg.quant_strat[0].PR.max; + ivas_spar_quant_dtx_init( &hMdEnc->spar_md, PR_minmax ); } - pState->spar_md_cfg.prior_strat = START; - pState->spar_md_cfg.prev_quant_idx = -1; + hMdEnc->spar_md_cfg.prior_strat = START; + hMdEnc->spar_md_cfg.prev_quant_idx = -1; for ( i = 0; i < num_channels; i++ ) { @@ -371,7 +371,7 @@ static ivas_error ivas_spar_md_enc_init( { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { - pState->mixer_mat[i][j][k] = 0; + hMdEnc->mixer_mat[i][j][k] = 0; } } } @@ -382,16 +382,16 @@ static ivas_error ivas_spar_md_enc_init( { for ( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) { - pState->cov_real[i][j][k] = 0; - pState->cov_dtx_real[i][j][k] = 0; + hMdEnc->cov_real[i][j][k] = 0; + hMdEnc->cov_dtx_real[i][j][k] = 0; } } } - ivas_clear_band_coeffs( pState->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); - ivas_clear_band_coeff_idx( pState->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); - ivas_clear_band_coeff_idx( pState->spar_md_prior.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); - ivas_clear_band_coeff_idx( pState->spar_md_prior.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeffs( hMdEnc->spar_md.band_coeffs, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeff_idx( hMdEnc->spar_md.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeff_idx( hMdEnc->spar_md_prior.band_coeffs_idx, IVAS_MAX_NUM_BANDS ); + ivas_clear_band_coeff_idx( hMdEnc->spar_md_prior.band_coeffs_idx_mapped, IVAS_MAX_NUM_BANDS ); return IVAS_ERR_OK; } @@ -400,11 +400,11 @@ static ivas_error ivas_spar_md_enc_init( /*-----------------------------------------------------------------------------------------* * Function ivas_spar_set_enc_config() * - * Set configuration for SPAR MD gen + * Set configuration for SPAR MD encoder *-----------------------------------------------------------------------------------------*/ static ivas_error ivas_spar_set_enc_config( - ivas_spar_md_enc_state_t *pState, + ivas_spar_md_enc_state_t *hMdEnc, int16_t *max_freq_per_chan, const int16_t nchan_transport, float *pFC, @@ -417,29 +417,29 @@ static ivas_error ivas_spar_set_enc_config( { if ( max_freq_per_chan != NULL ) { - pState->spar_md_cfg.max_freq_per_chan[i] = ( max_freq_per_chan[i] != 0 ) ? max_freq_per_chan[i] : max_freq_per_chan[0]; + hMdEnc->spar_md_cfg.max_freq_per_chan[i] = ( max_freq_per_chan[i] != 0 ) ? max_freq_per_chan[i] : max_freq_per_chan[0]; } else { - pState->spar_md_cfg.max_freq_per_chan[i] = IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN; + hMdEnc->spar_md_cfg.max_freq_per_chan[i] = IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN; } } - pState->num_umx_ch = nchan_inp; - pState->num_decorr = nchan_inp - 1; + hMdEnc->num_umx_ch = nchan_inp; + hMdEnc->num_decorr = nchan_inp - 1; for ( i = 0; i < IVAS_MAX_NUM_BANDS; i++ ) { tmp_dmx_ch = 0; for ( j = 0; j < nchan_transport; j++ ) { - if ( pFC[i] < pState->spar_md_cfg.max_freq_per_chan[j] ) + if ( pFC[i] < hMdEnc->spar_md_cfg.max_freq_per_chan[j] ) { tmp_dmx_ch += 1; } } - pState->spar_md_cfg.num_dmx_chans_per_band[i] = tmp_dmx_ch; - pState->spar_md_cfg.num_decorr_per_band[i] = pState->num_umx_ch - tmp_dmx_ch; + hMdEnc->spar_md_cfg.num_dmx_chans_per_band[i] = tmp_dmx_ch; + hMdEnc->spar_md_cfg.num_decorr_per_band[i] = hMdEnc->num_umx_ch - tmp_dmx_ch; } return IVAS_ERR_OK; @@ -564,7 +564,7 @@ ivas_error ivas_spar_md_enc_process( float pred_coeffs_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; float dm_fv_re[IVAS_SPAR_MAX_CH - 1][IVAS_MAX_NUM_BANDS]; - int16_t i, b, qsi, ndm, ndec, num_ch; + int16_t i, b, qsi, ndm, ndec, num_ch, num_quant_strats; int16_t j, planarCP; int16_t num_bands = pIn_buf->num_bands; int16_t dtx_vad = pIn_buf->dtx_vad; @@ -576,12 +576,11 @@ ivas_error ivas_spar_md_enc_process( BSTR_ENC_DATA hMetaData_tmp; Indice ind_list_tmp[MAX_BITS_METADATA]; // IVAS_fmToDo: size to be optimized float Wscale[IVAS_MAX_NUM_BANDS]; - ivas_spar_md_enc_state_t *pState = hMdEnc; - int16_t num_quant_strats = pState->spar_md_cfg.num_quant_strats; - + + num_quant_strats = hMdEnc->spar_md_cfg.num_quant_strats; num_ch = ivas_sba_get_nchan_metadata( sba_order ); - active_w = pState->spar_md_cfg.active_w; - nchan_transport = pState->spar_md_cfg.nchan_transport; + active_w = hMdEnc->spar_md_cfg.active_w; + nchan_transport = hMdEnc->spar_md_cfg.nchan_transport; if ( hEncoderConfig->ivas_total_brate == BRATE_SPAR_Q_STRAT && sba_order == 1 ) { @@ -616,8 +615,8 @@ ivas_error ivas_spar_md_enc_process( bands_bw = 1; } - ivas_compute_spar_params( pIn_buf->cov_real, dm_fv_re, 0, pState->mixer_mat, 0, nB, dtx_vad, num_ch, - bands_bw, active_w, &pState->spar_md_cfg, &pState->spar_md, Wscale, 0 ); + ivas_compute_spar_params( pIn_buf->cov_real, dm_fv_re, 0, hMdEnc->mixer_mat, 0, nB, dtx_vad, num_ch, + bands_bw, active_w, &hMdEnc->spar_md_cfg, &hMdEnc->spar_md, Wscale, 0 ); for ( i = 0; i < num_ch; i++ ) { @@ -625,7 +624,7 @@ ivas_error ivas_spar_md_enc_process( { for ( b = 0; b < num_bands; b++ ) { - hMdEnc->mixer_mat_local[i][j][b] = pState->mixer_mat[i][j][b]; + hMdEnc->mixer_mat_local[i][j][b] = hMdEnc->mixer_mat[i][j][b]; } } } @@ -644,7 +643,7 @@ ivas_error ivas_spar_md_enc_process( #ifdef SPAR_HOA_DBG fprintf( stdout, "qsi = %d\n", qsi ); #endif - if ( qsi == 2 && ivas_spar_br_table_consts[pState->table_idx].usePlanarCoeff ) + if ( qsi == 2 && ivas_spar_br_table_consts[hMdEnc->table_idx].usePlanarCoeff ) { planarCP = 1; #ifdef SPAR_HOA_DBG @@ -660,18 +659,18 @@ ivas_error ivas_spar_md_enc_process( { for ( b = 0; b < num_bands; b++ ) { - ndm = pState->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; + ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; if ( ndm != num_ch ) { - ivas_calc_c_p_coeffs( &pState->spar_md, pIn_buf->cov_real, 0, hMdEnc->mixer_mat_local, num_ch, ndm, b, dtx_vad, 1, planarCP ); + ivas_calc_c_p_coeffs( &hMdEnc->spar_md, pIn_buf->cov_real, 0, hMdEnc->mixer_mat_local, num_ch, ndm, b, dtx_vad, 1, planarCP ); } } } for ( b = 0; b < num_bands; b++ ) { - ndm = pState->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; - ndec = pState->spar_md_cfg.num_decorr_per_band[b * bands_bw]; + ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; + ndec = hMdEnc->spar_md_cfg.num_decorr_per_band[b * bands_bw]; if ( dtx_vad == 1 ) { @@ -715,10 +714,10 @@ ivas_error ivas_spar_md_enc_process( #endif } - ivas_quant_p_per_band( &pState->spar_md.band_coeffs[b], &pState->spar_md.band_coeffs_idx[b], &pState->spar_md_cfg.quant_strat[qsi], num_ch ); + ivas_quant_p_per_band( &hMdEnc->spar_md.band_coeffs[b], &hMdEnc->spar_md.band_coeffs_idx[b], &hMdEnc->spar_md_cfg.quant_strat[qsi], num_ch ); } - ivas_quant_pred_coeffs_per_band( &pState->spar_md.band_coeffs[b], &pState->spar_md.band_coeffs_idx[b], &pState->spar_md_cfg.quant_strat[qsi], num_ch ); + ivas_quant_pred_coeffs_per_band( &hMdEnc->spar_md.band_coeffs[b], &hMdEnc->spar_md.band_coeffs_idx[b], &hMdEnc->spar_md_cfg.quant_strat[qsi], num_ch ); } else { @@ -730,12 +729,12 @@ ivas_error ivas_spar_md_enc_process( float *P_re[IVAS_SPAR_MAX_CH - 1], *P_re_quant[IVAS_SPAR_MAX_CH - 1]; float **ppP_re = (float **) &P_re[0]; float **ppP_re_quant = (float **) &P_re_quant[0]; - int16_t *ppP_idx = &pState->spar_md.band_coeffs_idx[b].decd_index_re[0]; + int16_t *ppP_idx = &hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[0]; for ( i = 0; i < ndec; i++ ) { - ppP_re[i] = pState->spar_md.band_coeffs[b].P_re; - ppP_re_quant[i] = pState->spar_md.band_coeffs[b].P_quant_re; + ppP_re[i] = hMdEnc->spar_md.band_coeffs[b].P_re; + ppP_re_quant[i] = hMdEnc->spar_md.band_coeffs[b].P_quant_re; } ivas_quant_p_per_band_dtx( ppP_re, ndec, ndm, ppP_idx, ppP_re_quant, num_ch ); @@ -745,16 +744,16 @@ ivas_error ivas_spar_md_enc_process( ppPred_re = (float **) &pPred_re; ppPred_quant = (float **) &pPred_quant; - ppPred_re[0] = pState->spar_md.band_coeffs[b].pred_re; - ppPred_idx[0] = pState->spar_md.band_coeffs_idx[b].pred_index_re; - ppPred_quant[0] = pState->spar_md.band_coeffs[b].pred_quant_re; + ppPred_re[0] = hMdEnc->spar_md.band_coeffs[b].pred_re; + ppPred_idx[0] = hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re; + ppPred_quant[0] = hMdEnc->spar_md.band_coeffs[b].pred_quant_re; for ( i = 0; i < num_ch - 1; i++ ) { - pState->spar_md.band_coeffs[b].pred_quant_re[i] = 0; + hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i] = 0; } - ivas_spar_quant_pred_coeffs_dtx( &pState->spar_md, ppPred_re, ndm, ppPred_idx, num_ch - 1, ppPred_quant ); + ivas_spar_quant_pred_coeffs_dtx( &hMdEnc->spar_md, ppPred_re, ndm, ppPred_idx, num_ch - 1, ppPred_quant ); } } @@ -762,25 +761,25 @@ ivas_error ivas_spar_md_enc_process( { for ( b = 0; b < num_bands; b++ ) { - pred_coeffs_re[i][b] = Wscale[b] * pState->spar_md.band_coeffs[b].pred_quant_re[i]; + pred_coeffs_re[i][b] = Wscale[b] * hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i]; } } - ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, pState->mixer_mat, num_ch, 0, num_bands, active_w, &pState->spar_md_cfg ); + ivas_create_fullr_dmx_mat( pred_coeffs_re, dm_fv_re, hMdEnc->mixer_mat, num_ch, 0, num_bands, active_w, &hMdEnc->spar_md_cfg ); for ( b = 0; b < num_bands; b++ ) { - ndm = pState->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; - ndec = pState->spar_md_cfg.num_decorr_per_band[b * bands_bw]; + ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; + ndec = hMdEnc->spar_md_cfg.num_decorr_per_band[b * bands_bw]; for ( i = 0; i < num_ch; i++ ) { - pState->mixer_mat[0][i][b] *= Wscale[b]; + hMdEnc->mixer_mat[0][i][b] *= Wscale[b]; } if ( ( ndm != num_ch ) && ( ndm != 1 ) ) { - ivas_calc_c_p_coeffs( &pState->spar_md, pIn_buf->cov_real, 0, pState->mixer_mat, num_ch, ndm, b, dtx_vad, 0, planarCP ); + ivas_calc_c_p_coeffs( &hMdEnc->spar_md, pIn_buf->cov_real, 0, hMdEnc->mixer_mat, num_ch, ndm, b, dtx_vad, 0, planarCP ); #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n C coefficients: band %d\n", b); @@ -788,7 +787,7 @@ ivas_error ivas_spar_md_enc_process( { for (j = 0; j < ndm - 1; j++) { - fprintf(stderr, "%f, ", pState->spar_md.band_coeffs[b].C_re[i][j]); + fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].C_re[i][j]); } fprintf(stderr, "\n"); } @@ -802,7 +801,7 @@ ivas_error ivas_spar_md_enc_process( { for ( j = 0; j < ndm - 1; j++ ) { - pState->spar_md.band_coeffs[b].C_re[i][j] = 0.0f; + hMdEnc->spar_md.band_coeffs[b].C_re[i][j] = 0.0f; } } } @@ -813,7 +812,7 @@ ivas_error ivas_spar_md_enc_process( { for (j = 0; j < ndm - 1; j++) { - fprintf(stderr, "%f, ", pState->spar_md.band_coeffs[b].C_re[i][j]); // , pState->spar_md.band_coeffs[band_idx].C_im[i][j]); + fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].C_re[i][j]); // , hMdEnc->spar_md.band_coeffs[band_idx].C_im[i][j]); } fprintf(stderr, "\n"); } @@ -821,14 +820,14 @@ ivas_error ivas_spar_md_enc_process( #endif } - ivas_quant_c_per_band( &pState->spar_md.band_coeffs[b], &pState->spar_md.band_coeffs_idx[b], - &pState->spar_md_cfg.quant_strat[qsi], ndec, ndm ); + ivas_quant_c_per_band( &hMdEnc->spar_md.band_coeffs[b], &hMdEnc->spar_md.band_coeffs_idx[b], + &hMdEnc->spar_md_cfg.quant_strat[qsi], ndec, ndm ); #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n quantised C indexes: band %d\n", b); for (i = 0; i < ndec * (ndm-1); i++) { - fprintf(stderr, "%d, ", pState->spar_md.band_coeffs_idx[b].drct_index_re[i]); + fprintf(stderr, "%d, ", hMdEnc->spar_md.band_coeffs_idx[b].drct_index_re[i]); } fprintf(stderr, "\n\n");*/ #endif @@ -836,26 +835,26 @@ ivas_error ivas_spar_md_enc_process( } /* band limit downmix matrix */ - ivas_band_limit_dmx_matrix( pState, num_ch, num_bands, bands_bw ); + ivas_band_limit_dmx_matrix( hMdEnc, num_ch, num_bands, bands_bw ); /* band mixing */ if ( bands_bw > 1 ) { - ivas_band_mixing( pState, num_ch, num_bands, nchan_transport, pIn_buf->num_bands ); + ivas_band_mixing( hMdEnc, num_ch, num_bands, nchan_transport, pIn_buf->num_bands ); } - if ( pState->spar_md_cfg.gen_bs == 0 ) + if ( hMdEnc->spar_md_cfg.gen_bs == 0 ) { break; } if ( dtx_vad == 0 ) { - ivas_write_parameter_bitstream_dtx( &pState->spar_md, hMetaData, pState->spar_md_cfg.num_dmx_chans_per_band, pState->spar_md_cfg.num_decorr_per_band, num_bands ); + ivas_write_parameter_bitstream_dtx( &hMdEnc->spar_md, hMetaData, hMdEnc->spar_md_cfg.num_dmx_chans_per_band, hMdEnc->spar_md_cfg.num_decorr_per_band, num_bands ); break; } - ivas_select_next_strat( pState->spar_md_cfg.prior_strat, cs, dmx_switch, dtx_vad ); + ivas_select_next_strat( hMdEnc->spar_md_cfg.prior_strat, cs, dmx_switch, dtx_vad ); for ( i = 0; i < MAX_CODING_STRATS; i++ ) { @@ -864,13 +863,13 @@ ivas_error ivas_spar_md_enc_process( { reset_indices_enc( &hMetaData_tmp, MAX_BITS_METADATA ); - ivas_write_parameter_bitstream( pState, num_bands, bands_bw, &hMetaData_tmp, hEncoderConfig->ivas_total_brate, dtx_silence_mode, strat, qsi, planarCP ); + ivas_write_parameter_bitstream( hMdEnc, num_bands, bands_bw, &hMetaData_tmp, hEncoderConfig->ivas_total_brate, dtx_silence_mode, strat, qsi, planarCP ); if ( hMetaData->nb_bits_tot == bit_pos_start || hMetaData_tmp.nb_bits_tot < ( hMetaData->nb_bits_tot - bit_pos_start ) ) { write_metadata_buffer( &hMetaData_tmp, hMetaData, bit_pos_start, next_ind_start, last_ind_start ); code_strat = strat; } - if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == 1 ) ) ? 1 : 0 ) <= pState->spar_md_cfg.tgt_bits_per_blk ) + if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == 1 ) ) ? 1 : 0 ) <= hMdEnc->spar_md_cfg.tgt_bits_per_blk ) { packed_ok = 1; break; @@ -883,7 +882,7 @@ ivas_error ivas_spar_md_enc_process( break; } - if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == 1 ) ) ? 1 : 0 ) <= pState->spar_md_cfg.max_bits_per_blk ) + if ( hMetaData->nb_bits_tot - bit_pos_start + ( ( ( hEncoderConfig->ivas_total_brate == IVAS_256k ) && ( sba_order == 1 ) ) ? 1 : 0 ) <= hMdEnc->spar_md_cfg.max_bits_per_blk ) { break; } @@ -902,10 +901,10 @@ ivas_error ivas_spar_md_enc_process( fprintf( stdout, "\n\nMETADATA PR: band %d, qsi %d\n\n", b, qsi ); for ( i = 0; i < num_ch - 1; i++ ) { - fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //pState->spar_md.band_coeffs[b].pred_re[i], - pState->spar_md.band_coeffs[b].pred_quant_re[i], - pState->spar_md_prior.band_coeffs_idx[b].pred_index_re[i], - pState->spar_md.band_coeffs_idx[b].pred_index_re[i] ); + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].pred_re[i], + hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i], + hMdEnc->spar_md_prior.band_coeffs_idx[b].pred_index_re[i], + hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re[i] ); } fprintf( stdout, "\n\n METADATA C: band %d\n\n", b ); int16_t k = 0; @@ -913,31 +912,31 @@ ivas_error ivas_spar_md_enc_process( { for ( j = 0; j < ( ndm - 1 ); j++ ) { - fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, // pState->spar_md.band_coeffs[b].C_re[i][j], - pState->spar_md.band_coeffs[b].C_quant_re[i][j], - pState->spar_md_prior.band_coeffs_idx[b].drct_index_re[k], - pState->spar_md.band_coeffs_idx[b].drct_index_re[k] ); + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, // hMdEnc->spar_md.band_coeffs[b].C_re[i][j], + hMdEnc->spar_md.band_coeffs[b].C_quant_re[i][j], + hMdEnc->spar_md_prior.band_coeffs_idx[b].drct_index_re[k], + hMdEnc->spar_md.band_coeffs_idx[b].drct_index_re[k] ); k++; } } fprintf( stdout, "\n\n METADATA Pd: band %d\n\n", b ); for ( i = 0; i < num_ch - ndm; i++ ) { - fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //pState->spar_md.band_coeffs[b].P_re[i][i], - pState->spar_md.band_coeffs[b].P_quant_re[i][i], - pState->spar_md_prior.band_coeffs_idx[b].decd_index_re[i], - pState->spar_md.band_coeffs_idx[b].decd_index_re[i] ); + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].P_re[i][i], + hMdEnc->spar_md.band_coeffs[b].P_quant_re[i][i], + hMdEnc->spar_md_prior.band_coeffs_idx[b].decd_index_re[i], + hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[i] ); } fprintf( stdout, "\n\n" ); } }*/ b = 0; - ndm = pState->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; + ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; fprintf( stdout, "\n\n Metadata PR (15x1), C(15x15), P(15x15): band %d\n", b ); for ( i = 0; i < num_ch - 1; i++ ) { - fprintf( stdout, "i: %d -- %.2f\t|\t", i, pState->spar_md.band_coeffs[b].pred_quant_re[i] ); + fprintf( stdout, "i: %d -- %.2f\t|\t", i, hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i] ); if ( i < num_ch - ndm ) { if ( keep_planar[i] == 1 ) @@ -950,12 +949,12 @@ ivas_error ivas_spar_md_enc_process( } for ( j = 0; j < ndm - 1; j++ ) { - fprintf( stdout, "%.2f\t", pState->spar_md.band_coeffs[b].C_quant_re[i][j] ); + fprintf( stdout, "%.2f\t", hMdEnc->spar_md.band_coeffs[b].C_quant_re[i][j] ); } fprintf( stdout, "|\t" ); for ( j = 0; j < num_ch - ndm; j++ ) { - fprintf( stdout, "%.2f\t", pState->spar_md.band_coeffs[b].P_quant_re[j] ); + fprintf( stdout, "%.2f\t", hMdEnc->spar_md.band_coeffs[b].P_quant_re[j] ); } } fprintf( stdout, "\n" ); @@ -992,7 +991,7 @@ ivas_error ivas_spar_md_enc_process( ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; for ( i = 0; i < num_ch - 1; i++ ) { - dbgwrite( &pState->spar_md.band_coeffs[b].pred_re[i], sizeof( float ), 1, 1, f_name ); + dbgwrite( &hMdEnc->spar_md.band_coeffs[b].pred_re[i], sizeof( float ), 1, 1, f_name ); } sprintf( f_name, "spar_band_C_coeffs.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &nB, sizeof( nB ), 1, 1, f_name ) : false; @@ -1005,7 +1004,7 @@ ivas_error ivas_spar_md_enc_process( { for ( j = 0; j < ( ndm - 1 ); j++ ) { - dbgwrite( &pState->spar_md.band_coeffs[b].C_re[i][j], sizeof( float ), 1, 1, f_name ); + dbgwrite( &hMdEnc->spar_md.band_coeffs[b].C_re[i][j], sizeof( float ), 1, 1, f_name ); } } sprintf( f_name, "spar_band_P_coeffs.bin" ); @@ -1017,7 +1016,7 @@ ivas_error ivas_spar_md_enc_process( ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; for ( i = 0; i < num_ch - ndm; i++ ) { - dbgwrite( &pState->spar_md.band_coeffs[b].P_re[i], sizeof( float ), 1, 1, f_name ); + dbgwrite( &hMdEnc->spar_md.band_coeffs[b].P_re[i], sizeof( float ), 1, 1, f_name ); } sprintf( f_name, "spar_band_pred_coeffs_quant.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &nB, sizeof( nB ), 1, 1, f_name ) : false; @@ -1028,7 +1027,7 @@ ivas_error ivas_spar_md_enc_process( ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; for ( i = 0; i < num_ch - 1; i++ ) { - dbgwrite( &pState->spar_md.band_coeffs[b].pred_quant_re[i], sizeof( float ), 1, 1, f_name ); + dbgwrite( &hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i], sizeof( float ), 1, 1, f_name ); } sprintf( f_name, "spar_band_C_coeffs_quant.bin" ); ( b == 0 && frame == 0 ) ? dbgwrite( &nB, sizeof( nB ), 1, 1, f_name ) : false; @@ -1041,7 +1040,7 @@ ivas_error ivas_spar_md_enc_process( { for ( j = 0; j < ( ndm - 1 ); j++ ) { - dbgwrite( &pState->spar_md.band_coeffs[b].C_quant_re[i][j], sizeof( float ), 1, 1, f_name ); + dbgwrite( &hMdEnc->spar_md.band_coeffs[b].C_quant_re[i][j], sizeof( float ), 1, 1, f_name ); } } sprintf( f_name, "spar_band_P_coeffs_quant.bin" ); @@ -1053,7 +1052,7 @@ ivas_error ivas_spar_md_enc_process( ( b == 0 && frame == 0 ) ? dbgwrite( &byte_size, sizeof( byte_size ), 1, 1, f_name ) : false; for ( i = 0; i < num_ch - ndm; i++ ) { - dbgwrite( &pState->spar_md.band_coeffs[b].P_quant_re[i], sizeof( float ), 1, 1, f_name ); + dbgwrite( &hMdEnc->spar_md.band_coeffs[b].P_quant_re[i], sizeof( float ), 1, 1, f_name ); } } } @@ -1066,13 +1065,13 @@ ivas_error ivas_spar_md_enc_process( fclose( fp ); #endif - if ( pState->spar_md_cfg.gen_bs == 1 ) + if ( hMdEnc->spar_md_cfg.gen_bs == 1 ) { - ivas_store_prior_coeffs( pState, num_bands, bands_bw, code_strat, dtx_vad, qsi ); + ivas_store_prior_coeffs( hMdEnc, num_bands, bands_bw, code_strat, dtx_vad, qsi ); } - pState->spar_md.dtx_vad = dtx_vad; - pState->spar_md.num_bands = num_bands; + hMdEnc->spar_md.dtx_vad = dtx_vad; + hMdEnc->spar_md.num_bands = num_bands; return IVAS_ERR_OK; } -- GitLab