From 11224effb97fd0cd83e4d6889fb04ad7941ec70a Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 8 Sep 2023 18:23:11 +0200 Subject: [PATCH 1/3] fix 782: correct OSBA function names; under FIX_782_OSBA_FUNCTION_NAMES --- lib_com/ivas_prot.h | 35 +++++++++----- lib_com/options.h | 1 + lib_dec/ivas_dec.c | 4 ++ lib_dec/ivas_init_dec.c | 21 +++++++-- lib_dec/ivas_osba_dec.c | 101 +++++++++++++++++++++++++++++++++++++--- lib_dec/ivas_sba_dec.c | 13 +++++- lib_dec/ivas_stat_dec.h | 17 ++++++- 7 files changed, 168 insertions(+), 24 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 6893be758d..5981e43086 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -5653,36 +5653,47 @@ void ivas_osba_enc( const int32_t input_Fs /* i : input sampling rate */ ); +#ifdef FIX_782_OSBA_FUNCTION_NAMES +ivas_error ivas_osba_data_open( +#else ivas_error ivas_masa_ism_data_open( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +#endif + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); +#ifndef FIX_782_OSBA_FUNCTION_NAMES ivas_error ivas_sba_ism_separate_object_renderer_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); - +#endif ivas_error ivas_osba_dirac_td_binaural( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output[], /* o : output synthesis signal */ - const int16_t output_frame /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output[], /* o : output synthesis signal */ + const int16_t output_frame /* i : output frame length per channel */ ); ivas_error ivas_osba_ism_metadata_dec( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const int32_t ism_total_brate, /* i : ISM total bitrate */ - int16_t *nchan_ism, /* o : number of ISM separated channels */ - int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const int32_t ism_total_brate, /* i : ISM total bitrate */ + int16_t *nchan_ism, /* o : number of ISM separated channels */ + int16_t nb_bits_metadata[] /* o : number of ISM metadata bits */ ); ivas_error ivas_osba_render( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - float *output_f[], /* i/o: core-coder transport channels/object output */ - const int16_t output_frame /* i : output frame length per channel */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + float *output_f[], /* i/o: core-coder transport channels/object output */ + const int16_t output_frame /* i : output frame length per channel */ ); +#ifdef FIX_782_OSBA_FUNCTION_NAMES +void ivas_osba_data_close( + SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ +); +#else void ivas_masa_ism_data_close( MASA_ISM_DATA_HANDLE *hMasaIsmData /* i/o: MASA_ISM rendering handle */ ); +#endif /*----------------------------------------------------------------------------------* diff --git a/lib_com/options.h b/lib_com/options.h index dadd57e9bd..42ada5a89f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -162,6 +162,7 @@ #define FIX_730_DPID_NOT_SET_CORRECTLY /* Eri: issue 730: write dpid read from file in correct index, print informative error message when DPID specified is not found. */ #define FIX_RAM_COUNTING_5MS_RENDERING /* FhG: fix for correct RAM reporting with 5ms rendering */ +#define FIX_782_OSBA_FUNCTION_NAMES /* VA: fix 782: correct OSBA function names */ /* #################### End BE switches ################################## */ diff --git a/lib_dec/ivas_dec.c b/lib_dec/ivas_dec.c index 8d41109c07..1909825e97 100644 --- a/lib_dec/ivas_dec.c +++ b/lib_dec/ivas_dec.c @@ -760,7 +760,11 @@ ivas_error ivas_dec( { for ( n = 0; n < nchan_ism; n++ ) { +#ifdef FIX_782_OSBA_FUNCTION_NAMES + delay_signal( output[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); +#else delay_signal( output[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); +#endif } } diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 3a4d4f8130..b1df16bf48 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -1557,13 +1557,16 @@ ivas_error ivas_init_decoder( return error; } +#ifdef FIX_782_OSBA_FUNCTION_NAMES + if ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK ) +#else if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) +#endif { return error; } } - /* set CNA/CNG flags */ ivas_sba_set_cna_cng_flag( st_ivas ); } @@ -1669,7 +1672,7 @@ ivas_error ivas_init_decoder( st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); st_ivas->nSCE = 0; - st_ivas->nCPE = st_ivas->nchan_transport / 2; + st_ivas->nCPE = st_ivas->nchan_transport / CPE_CHANNELS; st_ivas->element_mode_init = IVAS_CPE_MDCT; @@ -1703,7 +1706,7 @@ ivas_error ivas_init_decoder( } st_ivas->nSCE = 0; - st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2; + st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / CPE_CHANNELS; st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; if ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) @@ -2069,6 +2072,7 @@ ivas_error ivas_init_decoder( return error; } } +#ifndef FIX_782_OSBA_FUNCTION_NAMES if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { /* Allocate 'hIsmRendererData' handle and memory for delay buffer within 'hMasaIsmData' */ @@ -2077,6 +2081,7 @@ ivas_error ivas_init_decoder( return error; } } +#endif } /*-----------------------------------------------------------------* @@ -2445,6 +2450,9 @@ void ivas_initialize_handles_dec( st_ivas->hHrtfParambin = NULL; st_ivas->hoa_dec_mtx = NULL; st_ivas->hMasaIsmData = NULL; +#ifdef FIX_782_OSBA_FUNCTION_NAMES + st_ivas->hSbaIsmData = NULL; +#endif st_ivas->hHeadTrackData = NULL; st_ivas->hHrtfTD = NULL; @@ -2653,8 +2661,14 @@ void ivas_destroy_dec( free( st_ivas->hMonoDmxRenderer ); st_ivas->hMonoDmxRenderer = NULL; } + +#ifdef FIX_782_OSBA_FUNCTION_NAMES + /* OSBA structure */ + ivas_osba_data_close( &st_ivas->hSbaIsmData ); +#else /* MASA ISM structure */ ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); +#endif /* OMASA structure */ ivas_omasa_data_close( &st_ivas->hMasaIsmData ); @@ -2682,6 +2696,7 @@ void ivas_destroy_dec( /* CRend binaural renderer handle */ ivas_HRTF_CRend_binary_close( &st_ivas->hSetOfHRTF ); + /* Fastconv HRTF memories */ ivas_binaural_hrtf_close( &st_ivas->hHrtfFastConv ); diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 0995089956..e248fa8891 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -43,6 +43,81 @@ #include "wmc_auto.h" +#ifdef FIX_782_OSBA_FUNCTION_NAMES +/*-------------------------------------------------------------------* + * ivas_osba_data_open() + * + * Allocate and initialize SBA_ISM rendering handle + *-------------------------------------------------------------------*/ + +ivas_error ivas_osba_data_open( + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +) +{ + SBA_ISM_DATA_HANDLE hSbaIsmData; + int16_t i; + + if ( ( hSbaIsmData = (SBA_ISM_DATA_HANDLE) malloc( sizeof( SBA_ISM_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for OSBA data\n" ) ); + } + + hSbaIsmData->delayBuffer_nchan = st_ivas->nchan_ism; + hSbaIsmData->delayBuffer_size = (int16_t) ( ( st_ivas->hDecoderConfig->output_Fs / 50 ) / MAX_PARAM_SPATIAL_SUBFRAMES ); + + if ( ( hSbaIsmData->delayBuffer = (float **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + } + + for ( i = 0; i < hSbaIsmData->delayBuffer_nchan; i++ ) + { + if ( ( hSbaIsmData->delayBuffer[i] = (float *) malloc( hSbaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + } + set_zero( hSbaIsmData->delayBuffer[i], hSbaIsmData->delayBuffer_size ); + } + + st_ivas->hSbaIsmData = hSbaIsmData; + + return IVAS_ERR_OK; +} + + +/*-------------------------------------------------------------------* + * ivas_osba_data_close() + * + * Deallocate SBA_ISM rendering handle + *-------------------------------------------------------------------*/ + +void ivas_osba_data_close( + SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ +) +{ + int16_t i; + + if ( hSbaIsmData == NULL || *hSbaIsmData == NULL ) + { + return; + } + + if ( ( *hSbaIsmData )->delayBuffer != NULL ) + { + for ( i = 0; i < ( *hSbaIsmData )->delayBuffer_nchan; i++ ) + { + free( ( *hSbaIsmData )->delayBuffer[i] ); + } + free( ( *hSbaIsmData )->delayBuffer ); + ( *hSbaIsmData )->delayBuffer = NULL; + } + + free( *hSbaIsmData ); + *hSbaIsmData = NULL; + + return; +} +#else /*-------------------------------------------------------------------* * ivas_masa_ism_data_open() * @@ -130,12 +205,13 @@ ivas_error ivas_sba_ism_separate_object_renderer_open( return IVAS_ERR_OK; } +#endif /*--------------------------------------------------------------------------* * ivas_osba_dirac_td_binaural() * - * Binaural rendering in OMASA format + * Binaural rendering in OSBA format *--------------------------------------------------------------------------*/ ivas_error ivas_osba_dirac_td_binaural( @@ -146,7 +222,6 @@ ivas_error ivas_osba_dirac_td_binaural( { int16_t n; float data_separated_objects[MAX_NUM_OBJECTS][L_FRAME48k]; - ivas_error error; float *p_sepobj[MAX_NUM_OBJECTS]; int16_t channel_offset; @@ -164,13 +239,16 @@ ivas_error ivas_osba_dirac_td_binaural( } #ifdef OSBA_SPLIT_RENDERING - if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && - st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) + if ( st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) #endif { for ( n = 0; n < st_ivas->nchan_ism; n++ ) { +#ifdef FIX_782_OSBA_FUNCTION_NAMES + delay_signal( data_separated_objects[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); +#else delay_signal( data_separated_objects[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); +#endif } } @@ -183,8 +261,7 @@ ivas_error ivas_osba_dirac_td_binaural( } else { - ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport, - MAX_PARAM_SPATIAL_SUBFRAMES ); + ivas_dirac_dec_binaural( st_ivas, st_ivas->hCombinedOrientationData, &output[channel_offset], st_ivas->nchan_transport, MAX_PARAM_SPATIAL_SUBFRAMES ); } #ifdef DEBUG_OSBA @@ -266,6 +343,12 @@ ivas_error ivas_osba_dirac_td_binaural( } +/*-------------------------------------------------------------------------* + * ivas_osba_ism_metadata_dec() + * + * ISM metadata decoding in OSBA format. + *-------------------------------------------------------------------------*/ + ivas_error ivas_osba_ism_metadata_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const int32_t ism_total_brate, /* i : ISM total bitrate */ @@ -280,7 +363,6 @@ ivas_error ivas_osba_ism_metadata_dec( nchan_transport_ism = st_ivas->nchan_ism; *nchan_ism = st_ivas->nchan_ism; - /* decode ISM metadata */ if ( ( error = ivas_ism_metadata_dec( ism_total_brate, *nchan_ism, &nchan_transport_ism, st_ivas->hIsmMetaData, NULL, st_ivas->bfi, nb_bits_metadata, st_ivas->ism_mode, st_ivas->hISMDTX, NULL, &st_ivas->ism_extmeta_active, &st_ivas->ism_extmeta_cnt, st_ivas->hCPE[0]->hCoreCoder[0] ) ) != IVAS_ERR_OK ) @@ -291,6 +373,7 @@ ivas_error ivas_osba_ism_metadata_dec( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------------* * ivas_osba_render() * @@ -329,7 +412,11 @@ ivas_error ivas_osba_render( for ( n = 0; n < nchan_ism; n++ ) { mvr2r( output_f[n], tmp_ism_out[n], output_frame ); +#ifdef FIX_782_OSBA_FUNCTION_NAMES + delay_signal( tmp_ism_out[n], output_frame, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size ); +#else delay_signal( tmp_ism_out[n], output_frame, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); +#endif } if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI ) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index f2e99927b7..7263577e74 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -367,6 +367,7 @@ ivas_error ivas_sba_dec_reconfigure( /*-----------------------------------------------------------------* * Allocate, initialize, and configure SCE/CPE/MCT handles *-----------------------------------------------------------------*/ + if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { if ( ism_mode_old == ISM_MODE_NONE && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) @@ -393,6 +394,7 @@ ivas_error ivas_sba_dec_reconfigure( return error; } } + if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { /* Allocate TD renderer for the objects in DISC mode */ @@ -404,6 +406,14 @@ ivas_error ivas_sba_dec_reconfigure( } } } + +#ifdef FIX_782_OSBA_FUNCTION_NAMES + /* Allocate memory for OSBA delay buffer */ + if ( ( error = ivas_osba_data_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#else if ( ( error = ivas_masa_ism_data_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; @@ -413,6 +423,7 @@ ivas_error ivas_sba_dec_reconfigure( { return error; } +#endif #ifndef NONBE_FIX_752_OSBA_MISCONFIG_MCT st_ivas->nchan_transport += st_ivas->nchan_ism; @@ -429,7 +440,7 @@ ivas_error ivas_sba_dec_reconfigure( st_ivas->hIsmRendererData = NULL; } ivas_ism_metadata_close( st_ivas->hIsmMetaData, 0 ); - ivas_masa_ism_data_close( &st_ivas->hMasaIsmData ); + ivas_osba_data_close( &st_ivas->hSbaIsmData ); /* Time Domain binaural renderer handle */ diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 9cc26a06ce..12023114f4 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -656,6 +656,18 @@ typedef struct ivas_spar_dec_lib_t } SPAR_DEC_DATA, *SPAR_DEC_HANDLE; +#ifdef FIX_782_OSBA_FUNCTION_NAMES +/* Data structure for SBA_ISM rendering */ +typedef struct ivas_osba_data +{ + float **delayBuffer; + int16_t delayBuffer_size; + int16_t delayBuffer_nchan; + +} SBA_ISM_DATA, *SBA_ISM_DATA_HANDLE; +#endif + + /*----------------------------------------------------------------------------------* * SCE decoder structure *----------------------------------------------------------------------------------*/ @@ -1086,7 +1098,10 @@ typedef struct Decoder_Struct COMBINED_ORIENTATION_HANDLE hCombinedOrientationData; /* Combined external and head orientation data structure */ DIRAC_REND_HANDLE hDirACRend; /* DirAC renderer handle */ SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; /* Spatial parametric (DirAC rend, ParamBin, ParamISM) rendering common data handle. */ - MASA_ISM_DATA_HANDLE hMasaIsmData; + MASA_ISM_DATA_HANDLE hMasaIsmData; /* OMASA rendering handle */ +#ifdef FIX_782_OSBA_FUNCTION_NAMES + SBA_ISM_DATA_HANDLE hSbaIsmData; /* OSBA rendering handle */ +#endif int16_t flag_omasa_brate; -- GitLab From 8e346574b0597675b2a348d3f9b98f9b4d7c84f1 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 8 Sep 2023 18:24:53 +0200 Subject: [PATCH 2/3] correct printout --- lib_dec/ivas_osba_dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index e248fa8891..2cec5ef03c 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -67,14 +67,14 @@ ivas_error ivas_osba_data_open( if ( ( hSbaIsmData->delayBuffer = (float **) malloc( hSbaIsmData->delayBuffer_nchan * sizeof( float * ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) ); } for ( i = 0; i < hSbaIsmData->delayBuffer_nchan; i++ ) { if ( ( hSbaIsmData->delayBuffer[i] = (float *) malloc( hSbaIsmData->delayBuffer_size * sizeof( float ) ) ) == NULL ) { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for MASA ISM delay buffer \n" ) ); + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for OSBA delay buffer \n" ) ); } set_zero( hSbaIsmData->delayBuffer[i], hSbaIsmData->delayBuffer_size ); } -- GitLab From 0f173a7c539ad58e763d1cd450c63400433d62ae Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 19 Sep 2023 19:08:00 +0200 Subject: [PATCH 3/3] clang-format --- lib_dec/ivas_sba_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 3b3d5c3542..8895ebf0cb 100755 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -751,7 +751,7 @@ ivas_error ivas_sba_dec_render( if ( ( error = ivas_sba_linear_renderer( output_f, *nSamplesRendered, st_ivas->hIntSetup.nchan_out_woLFE, 0, st_ivas->hDecoderConfig->output_config, st_ivas->hOutSetup, st_ivas->hoa_dec_mtx ) ) != IVAS_ERR_OK ) { return error; - } + } } if ( st_ivas->hDirAC != NULL && hSpar->slots_rendered == hSpar->num_slots ) -- GitLab