diff --git a/lib_com/delay_comp.c b/lib_com/delay_comp.c index a957150b936957da3f6919c6ee17e893508433c5..dddc100f5830588a579307aef67ea20c97cec3d4 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 83488b2b6441ecd3b318fc228f0480067d63e1f0..8a35f4f6f43c91477f71e36fa50b8837baa11669 100755 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -171,6 +171,7 @@ #define FIX_221_BR_SWITCH_STEREO /* Issue 221: Fix missing initialization when switchin from TD to MDCT stereo*/ #define FIX_DTX_RANGE /* Issue 118: fix the DTX usage: default DTX up to 64 kbps, otherwise only in silence */ #define FIX_ISM_METADATA_READER /* Issue 211: make ISM metadata file reader robust against invalid files */ +#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 657bb484c26751dc21b182c2f98168161fd40de6..57a161f225a9cf830f05d4a4e6b3224c037b70c9 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 d16d1f24945399b8e536242c5e1eb8365d1c749d..70e038483962294e2e4bdb89e4c62609d965e2ad 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 063375ef59dbb88cda23e7085b2ac62e633d538c..b3f8dc478d3c9fd3e077233c63a1c720fa0598cc 100755 --- a/lib_enc/lib_enc.c +++ b/lib_enc/lib_enc.c @@ -963,7 +963,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;