From b4071947236c8dec616038d2bb02e8bc4031e2d3 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 25 Nov 2022 11:12:05 +0100 Subject: [PATCH] fix Issue 223: change return data type in function get_delay(); under FIX_GET_DELAY_RETURN --- lib_com/delay_comp.c | 14 +++++++++++--- lib_com/options.h | 1 + lib_com/prot.h | 16 ++++++++++------ lib_dec/lib_dec.c | 4 ++++ lib_enc/lib_enc.c | 4 ++++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index a957150b93..dddc100f58 100644 --- a/lib_com/delay_comp.c +++ b/lib_com/delay_comp.c @@ -50,8 +50,12 @@ *--------------------------------------------------------------------------*/ /*! r: delay value in ns */ +#ifdef FIX_GET_DELAY_RETURN +int32_t get_delay( +#else float get_delay( - const int16_t what_delay, /* i : what delay? (ENC or DEC) */ +#endif + const int16_t enc_dec, /* i : encoder/decoder flag */ const int32_t io_fs, /* i : input/output sampling frequency */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ @@ -59,9 +63,13 @@ float get_delay( const int32_t binaural_latency_ns /* i : binaural renderer HRTF delay in ns */ ) { +#ifdef FIX_GET_DELAY_RETURN + int32_t delay = 0; +#else float delay = 0; +#endif - if ( what_delay == ENC ) + if ( enc_dec == ENC ) { if ( ivas_format == MONO_FORMAT ) /* EVS mono */ { @@ -78,7 +86,7 @@ float get_delay( delay += IVAS_FB_ENC_DELAY_NS; } } - else + else /* DEC */ { if ( ivas_format == MONO_FORMAT ) /* EVS mono */ { diff --git a/lib_com/options.h b/lib_com/options.h index 21fe824853..2d30a38dd2 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -167,6 +167,7 @@ #ifdef FIX_185_REDUCE_MD_BITS #define CLEANUP_185_NO_AGC_EXCEPTION /* Issue 185: Cleanup AGC EXCEPTION code */ #endif +#define FIX_GET_DELAY_RETURN /* Issue 223: change return data type in function get_delay() */ /* ################## End DEVELOPMENT switches ######################### */ diff --git a/lib_com/prot.h b/lib_com/prot.h index 2d6527fe59..6e10f8c57f 100755 --- a/lib_com/prot.h +++ b/lib_com/prot.h @@ -712,13 +712,17 @@ int16_t lev_dur( ); /*! r: delay value in ns */ +#ifdef FIX_GET_DELAY_RETURN +int32_t get_delay( +#else float get_delay( - const int16_t what_delay, /* i : what delay? (ENC or DEC) */ - const int32_t io_fs, /* i : input/output sampling frequency */ - const IVAS_FORMAT ivas_format, /* i : IVAS format */ - HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ - RENDERER_TYPE renderer_type, /* i : IVAS rendering type */ - const int32_t binaural_latency_ns /* i : binaural renderer HRTF delay in ns */ +#endif + const int16_t enc_dec, /* i : encoder/decoder flag */ + const int32_t io_fs, /* i : input/output sampling frequency */ + const IVAS_FORMAT ivas_format, /* i : IVAS format */ + HANDLE_CLDFB_FILTER_BANK hCldfb, /* i : Handle of Cldfb analysis */ + RENDERER_TYPE renderer_type, /* i : IVAS rendering type */ + const int32_t binaural_latency_ns /* i : binaural renderer HRTF delay in ns */ ); void decision_matrix_enc( diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index d16d1f2494..70e0384839 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1055,7 +1055,11 @@ ivas_error IVAS_DEC_GetDelay( st_ivas = hIvasDec->st_ivas; hDecoderConfig = st_ivas->hDecoderConfig; +#ifdef FIX_GET_DELAY_RETURN + *nSamples = NS2SA( hDecoderConfig->output_Fs, get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], st_ivas->renderer_type, st_ivas->binaural_latency_ns ) ); +#else *nSamples = NS2SA( hDecoderConfig->output_Fs, (int32_t) ( get_delay( DEC, hDecoderConfig->output_Fs, st_ivas->ivas_format, st_ivas->cldfbAnaDec[0], st_ivas->renderer_type, st_ivas->binaural_latency_ns ) + 0.5f ) ); +#endif *timeScale = hDecoderConfig->output_Fs; diff --git a/lib_enc/lib_enc.c b/lib_enc/lib_enc.c index 68a465a5bc..398098a839 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -954,7 +954,11 @@ ivas_error IVAS_ENC_GetDelay( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_GET_DELAY_RETURN + *delay = NS2SA( hEncoderConfig->input_Fs, get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, RENDERER_DISABLE, 0 ) ); +#else *delay = NS2SA( hEncoderConfig->input_Fs, (int32_t) ( get_delay( ENC, hEncoderConfig->input_Fs, hEncoderConfig->ivas_format, NULL, RENDERER_DISABLE, 0 ) + 0.5f ) ); +#endif *delay *= hEncoderConfig->nchan_inp; -- GitLab