From c308d7f6a373311523547d42d387130c98e754da Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sun, 28 Jan 2024 14:21:37 +0530 Subject: [PATCH] functions in ivas_ls_custom_dec converted to fixed --- lib_com/ivas_prot_fx.h | 14 +++++++ lib_dec/ivas_init_dec.c | 22 +++++++++++ lib_dec/ivas_ls_custom_dec.c | 72 ++++++++++++++++++++++++++++++++++++ lib_rend/ivas_stat_rend.h | 6 +++ 4 files changed, 114 insertions(+) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index f43642d8d..a21a55f5f 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -707,4 +707,18 @@ Word16 stereo_dft_band_config_fx( const Word16 NFFT, /* i : analysis/synthesis window length */ const Word16 enc_dec /* i : flag to indicate enc vs dec */ ); + +// ivas_ls_custom_dec.c +void ivas_ls_custom_setup_fx( + IVAS_OUTPUT_SETUP_HANDLE hOutSetup, /* o : IVAS output setup handle */ + const LSSETUP_CUSTOM_STRUCT *hLsSetupCustom /* i : Custom loudspeaker setup handle */ +); + +ivas_error ivas_ls_custom_output_init_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +); + +ivas_error ivas_ls_custom_open_fx( + LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ +); #endif \ No newline at end of file diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 388a8a6fb..da1c7e2bd 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -732,7 +732,17 @@ ivas_error ivas_init_decoder_front( IF ( st_ivas->hDecoderConfig->Opt_LsCustom ) { +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_ls_custom_open_fx( &( st_ivas->hLsSetupCustom ) ) ) == IVAS_ERR_OK ) + { + set_zero((st_ivas->hLsSetupCustom)->ls_azimuth, MAX_OUTPUT_CHANNELS ); + set_zero((st_ivas->hLsSetupCustom)->ls_elevation, MAX_OUTPUT_CHANNELS ); + set_f( ( st_ivas->hLsSetupCustom )->separate_ch_gains, 0.0f, MAX_OUTPUT_CHANNELS ); + } + ELSE +#else IF ( ( error = ivas_ls_custom_open( &( st_ivas->hLsSetupCustom ) ) ) != IVAS_ERR_OK ) +#endif { return error; } @@ -927,7 +937,19 @@ ivas_error ivas_init_decoder( IF ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) { +#ifdef IVAS_FLOAT_FIXED + IF ( ( error = ivas_ls_custom_output_init_fx( st_ivas ) ) == IVAS_ERR_OK ) { + + st_ivas->hOutSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; + st_ivas->hOutSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; + st_ivas->hIntSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; + st_ivas->hIntSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; + + } + ELSE +#else IF ( ( error = ivas_ls_custom_output_init( st_ivas ) ) != IVAS_ERR_OK ) +#endif { return error; } diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index e926b1fbe..15081bd91 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -34,6 +34,10 @@ #include "ivas_prot.h" #include "prot.h" #include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#include "prot_fx1.h" +#endif /*-----------------------------------------------------------------------* @@ -67,6 +71,32 @@ ivas_error ivas_ls_custom_open( return IVAS_ERR_OK; } +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_ls_custom_open_fx( + LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ +) +{ + /* Allocate handle */ + IF ( ( *hLsSetupCustom = (LSSETUP_CUSTOM_HANDLE) malloc( sizeof( LSSETUP_CUSTOM_STRUCT ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Custom LS layout memory\n" ) ); + } + + ( *hLsSetupCustom )->num_spk = -1; + ( *hLsSetupCustom )->is_planar_setup = -1; + + set16_fx( ( *hLsSetupCustom )->ls_azimuth_fx, 0, MAX_OUTPUT_CHANNELS ); + set16_fx( ( *hLsSetupCustom )->ls_elevation_fx, 0, MAX_OUTPUT_CHANNELS ); + + ( *hLsSetupCustom )->num_lfe = -1; + set_s( ( *hLsSetupCustom )->lfe_idx, -1, MAX_OUTPUT_CHANNELS ); + + ( *hLsSetupCustom )->separate_ch_found = -1; + + set16_fx( ( *hLsSetupCustom )->separate_ch_gains_fx, 0, MAX_OUTPUT_CHANNELS ); + return IVAS_ERR_OK; +} +#endif /*-------------------------------------------------------------------------* * ivas_output_init_ls_custom() @@ -94,6 +124,29 @@ void ivas_ls_custom_setup( return; } +#ifdef IVAS_FLOAT_FIXED +void ivas_ls_custom_setup_fx( + IVAS_OUTPUT_SETUP_HANDLE hOutSetup, /* o : IVAS output setup handle */ + const LSSETUP_CUSTOM_STRUCT *hLsSetupCustom /* i : Custom loudspeaker setup handle */ +) +{ + hOutSetup->output_config = IVAS_AUDIO_CONFIG_LS_CUSTOM; + + hOutSetup->nchan_out_woLFE = hLsSetupCustom->num_spk; + + hOutSetup->ls_azimuth_fx = hLsSetupCustom->ls_azimuth_fx; + hOutSetup->ls_elevation_fx = hLsSetupCustom->ls_elevation_fx; + + hOutSetup->num_lfe = hLsSetupCustom->num_lfe; + hOutSetup->index_lfe[0] = hLsSetupCustom->lfe_idx[0]; /* IVAS_OUTPUT_SETUP only supports 1 LFE */ + + hOutSetup->is_loudspeaker_setup = TRUE; + hOutSetup->is_planar_setup = (int8_t) hLsSetupCustom->is_planar_setup; + + return; +} +#endif + /*-----------------------------------------------------------------------* * ivas_ls_custom_output_init() * @@ -116,3 +169,22 @@ ivas_error ivas_ls_custom_output_init( return IVAS_ERR_OK; } + +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_ls_custom_output_init_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +) +{ + IF ( st_ivas->hLsSetupCustom == NULL ) + { + return IVAS_ERR_WRONG_PARAMS; + } + + st_ivas->hDecoderConfig->nchan_out = add( st_ivas->hLsSetupCustom->num_spk, st_ivas->hLsSetupCustom->num_lfe ); + + ivas_ls_custom_setup_fx( &( st_ivas->hOutSetup ), st_ivas->hLsSetupCustom ); + ivas_ls_custom_setup_fx( &( st_ivas->hIntSetup ), st_ivas->hLsSetupCustom ); + + return IVAS_ERR_OK; +} +#endif diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index b641711e1..71b008e52 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -82,6 +82,9 @@ typedef struct ivas_output_setup_structure const float *ls_azimuth; const float *ls_elevation; + const Word16 *ls_azimuth_fx; + const Word16 *ls_elevation_fx; + uint8_t separateChannelEnabled; int16_t separateChannelIndex; @@ -1713,6 +1716,9 @@ typedef struct ivas_LS_setup_custom int16_t separate_ch_found; /* flag to indicate if a center channel was found */ float separate_ch_gains[MAX_OUTPUT_CHANNELS]; /* gains to pan McMASA separateChannel in case no center channel is present */ + Word16 ls_azimuth_fx[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker azimuths */ + Word16 ls_elevation_fx[MAX_OUTPUT_CHANNELS]; /* custom loudspeaker elevations */ + Word16 separate_ch_gains_fx[MAX_OUTPUT_CHANNELS]; /* gains to pan McMASA separateChannel in case no center channel is present */ } LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; -- GitLab