From 06323c4235162cae551f6197cd991c68acb30fba Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 3 Sep 2024 10:01:27 +0200 Subject: [PATCH 01/18] fix formal issues --- apps/decoder.c | 46 ++--- lib_com/common_api_types.h | 1 + lib_com/ivas_prot.h | 20 +- lib_dec/ivas_ism_dec.c | 2 + lib_dec/ivas_ism_param_dec.c | 15 +- lib_dec/ivas_ism_renderer.c | 1 + lib_dec/ivas_jbm_dec.c | 37 +--- lib_dec/ivas_mc_param_dec.c | 4 +- lib_dec/ivas_objectRenderer_internal.c | 2 + lib_dec/ivas_omasa_dec.c | 2 + lib_dec/ivas_osba_dec.c | 53 ++++++ lib_dec/lib_dec.c | 185 ++++++++++--------- lib_dec/lib_dec.h | 37 ++-- lib_rend/ivas_dirac_dec_binaural_functions.c | 3 +- lib_rend/ivas_objectRenderer.c | 1 + lib_rend/ivas_objectRenderer_sources.c | 17 +- lib_rend/ivas_prot_rend.h | 12 +- 17 files changed, 259 insertions(+), 179 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 5eb6d9f16f..4a943ddaa1 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -54,11 +54,6 @@ #include "debug.h" #endif #include "wmc_auto.h" -#ifdef OBJ_EDITING_API -#ifdef OBJ_EDITING_EXAMPLE -#include -#endif -#endif #define WMC_TOOL_SKIP @@ -1101,10 +1096,8 @@ static bool parseCmdlIVAS_dec( #ifdef OBJ_EDITING_EXAMPLE arg->objEditEnabled = false; -#endif -# - +#endif /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -1557,7 +1550,6 @@ static bool parseCmdlIVAS_dec( i += tmp; } - #ifdef OBJ_EDITING_EXAMPLE else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 ) { @@ -2140,10 +2132,6 @@ static ivas_error decodeG192( return error; } -#ifdef OBJ_EDITING_API - IVAS_EDITABLE_PARAMETERS editableParameters; -#endif - IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; @@ -2445,23 +2433,23 @@ static ivas_error decodeG192( } #endif /* Feed into decoder */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi #ifdef OBJ_EDITING_API - , - isSplitRend, - splitRendBits + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + #ifdef OBJ_EDITING_API #ifdef OBJ_EDITING_EXAMPLE + /* Do object info editing */ if ( arg.objEditEnabled ) { + IVAS_EDITABLE_PARAMETERS editableParameters; - /* Do object info editing here */ /* get object parameters */ if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) { @@ -2484,6 +2472,7 @@ static ivas_error decodeG192( num_nondiegetic_objects++; } } + if ( num_nondiegetic_objects ) { float start_angle, angle_inc; @@ -2508,13 +2497,14 @@ static ivas_error decodeG192( editableParameters.gain_bed = 0.5f; - /* set new object parameters*/ + /* set new object parameters */ if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } } + #endif /* Do the final preparations needed for rendering */ if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) @@ -3362,26 +3352,24 @@ static ivas_error decodeVoIP( while ( nSamplesRendered < nOutSamples ) { #endif - #ifdef SUPPORT_JBM_TRACEFILE - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter #ifdef OBJ_EDITING_API - , - &nSamplesRendered, ¶meterAvailableForEditing + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing #ifdef OBJ_EDITING_API - & nSamplesRendered, - ¶meterAvailableForEditing + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing & nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } + #ifdef OBJ_EDITING_API if ( parameterAvailableForEditing == true ) { diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 8cbdfcb3cd..4f9e728e20 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -140,6 +140,7 @@ typedef struct _IVAS_EDITABLE_PARAMETERS int16_t num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; float gain_bed; + } IVAS_EDITABLE_PARAMETERS; #endif diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index da1f94daed..7eb05df26b 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1105,12 +1105,12 @@ void ivas_param_ism_dec_digest_tc( #ifdef OBJ_EDITING_API void ivas_param_ism_dec_dequant_md( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); void ivas_param_ism_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ); #endif @@ -5622,6 +5622,18 @@ ivas_error ivas_osba_render_sf( float *output_f[] /* o : rendered time signal */ ); +#ifdef OBJ_EDITING_API +void ivas_osba_stereo_add_channels( + float *tc_f[], /* i : transport channels */ + float *output_f[], /* i/o: output channels */ + const float gain, /* i : gain bed value */ + const int16_t nchan_out, /* i : number of output channels */ + const int16_t nchan_ism, /* i : number of ISM channels */ + const int16_t ism_mode, /* i : ISM mode */ + const int16_t n_samples_to_render /* i : output frame length per channel */ +); +#endif + void ivas_osba_data_close( SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ ); @@ -5630,6 +5642,8 @@ ISM_MODE ivas_osba_ism_mode_select( const int32_t ivas_total_brate, /* i : IVAS total bitrate */ const int16_t nchan_ism /* i : number of input ISM's */ ); + + /*----------------------------------------------------------------------------------* * OMASA prototypes *---------------------------------------------------------------------------------*/ diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 36945f8155..0dd9710317 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -177,9 +177,11 @@ static ivas_error ivas_ism_bitrate_switching_dec( { /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin ); + #ifdef OBJ_EDITING_PARAMISM_BIN /* Close omasa data struct (used for object editing) */ ivas_omasa_data_close( &st_ivas->hMasaIsmData ); + #endif /* Open the TD Binaural renderer */ if ( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL ) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index b4a37dddf6..8a1dd942d8 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -860,8 +860,8 @@ void ivas_param_ism_dec_digest_tc( nchan_out = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; } -#endif +#endif push_wmops( "ivas_param_ism_dec_digest_tc" ); #ifndef OBJ_EDITING_API @@ -939,8 +939,8 @@ void ivas_param_ism_dec_digest_tc( } } } -#endif +#endif if ( st_ivas->hDecoderConfig->Opt_tsm ) { /*TODO : FhG to check*/ @@ -954,7 +954,6 @@ void ivas_param_ism_dec_digest_tc( { if ( st_ivas->hDecoderConfig->Opt_tsm ) { - float RealBuffer[CLDFB_NO_CHANNELS_MAX]; float ImagBuffer[CLDFB_NO_CHANNELS_MAX]; @@ -962,8 +961,8 @@ void ivas_param_ism_dec_digest_tc( mvr2r( RealBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); mvr2r( ImagBuffer, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands ); } - #ifndef OBJ_EDITING_API + ivas_param_ism_collect_slot( hParamIsmDec, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], ch, ref_power, cx_diag ); #endif } @@ -988,13 +987,14 @@ void ivas_param_ism_dec_digest_tc( #ifdef OBJ_EDITING_API /*-------------------------------------------------------------------------* - * ivas_param_ism_dec_prepare_renderer() + * ivas_param_ism_dec_dequant_md() * * *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_dequant_md( - Decoder_Struct *st_ivas ) + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ +) { /* De-quantization */ if ( !( st_ivas->hDecoderConfig->ivas_total_brate == IVAS_SID_5k2 || st_ivas->hDecoderConfig->ivas_total_brate == FRAME_NO_DATA ) ) @@ -1460,8 +1460,8 @@ void ivas_param_ism_params_to_masa_param_mapping( { st_ivas->hISMDTX.dtx_flag = 1; } -#endif +#endif if ( st_ivas->hISMDTX.dtx_flag ) { float energy_ratio; @@ -1534,6 +1534,7 @@ void ivas_param_ism_params_to_masa_param_mapping( hSpatParamRendCom->surroundingCoherence[sf_idx][bin_idx] = 0.0; } } + #ifdef OBJ_EDITING_PARAMISM_BIN for ( obj = 0; obj < st_ivas->nchan_ism; obj++ ) { diff --git a/lib_dec/ivas_ism_renderer.c b/lib_dec/ivas_ism_renderer.c index ae6e452313..fb07803cec 100644 --- a/lib_dec/ivas_ism_renderer.c +++ b/lib_dec/ivas_ism_renderer.c @@ -247,6 +247,7 @@ void ivas_ism_render_sf( rotateAziEle( st_ivas->hIsmMetaData[i]->last_azimuth, st_ivas->hIsmMetaData[i]->last_elevation, &azimuth, &elevation, st_ivas->hCombinedOrientationData->Rmat[st_ivas->hCombinedOrientationData->subframe_idx], st_ivas->hIntSetup.is_planar_setup ); #endif } + if ( st_ivas->hEFAPdata != NULL ) { efap_determine_gains( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains[i], azimuth, elevation, EFAP_MODE_EFAP ); diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 6eea0419a2..03663aed8b 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -150,6 +150,7 @@ ivas_error ivas_jbm_dec_tc( } ivas_ism_dtx_limit_noise_energy_for_near_silence( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport ); + #ifdef OBJ_EDITING_API ivas_param_ism_dec_dequant_md( st_ivas ); #endif @@ -160,6 +161,7 @@ ivas_error ivas_jbm_dec_tc( { return error; } + #ifdef OBJ_EDITING_API ivas_param_ism_dec_dequant_md( st_ivas ); #endif @@ -1248,36 +1250,15 @@ ivas_error ivas_jbm_dec_render( /* add already rendered SBA part */ #ifdef OBJ_EDITING_API - if ( st_ivas->ivas_format == SBA_ISM_FORMAT && st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - float gain = st_ivas->hSbaIsmData->gain_bed; - if ( gain != 1.0f && gain >= 0.0f ) - { - int16_t i; - for ( n = 0; n < nchan_out; n++ ) - { - for ( i = 0; i < *nSamplesRendered; i++ ) - { - p_output[n][i] += p_tc[n + st_ivas->nchan_ism][i] * gain; - } - } - } - else - { - for ( n = 0; n < nchan_out; n++ ) - { - v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); - } - } - } - else -#endif + ivas_osba_stereo_add_channels( p_tc, p_output, st_ivas->hSbaIsmData->gain_bed, nchan_out, st_ivas->nchan_ism, st_ivas->ism_mode, *nSamplesRendered ); +#else { for ( n = 0; n < nchan_out; n++ ) { v_add( p_output[n], p_tc[n + st_ivas->nchan_ism], p_output[n], *nSamplesRendered ); } } +#endif } else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) { @@ -2999,6 +2980,7 @@ void ivas_jbm_masa_sf_to_sf_map( return; } + #ifdef OBJ_EDITING_API /*--------------------------------------------------------------------------* * ivas_jbm_dec_prepare_renderer() @@ -3055,7 +3037,6 @@ void ivas_jbm_dec_prepare_renderer( } else if ( st_ivas->ivas_format == SBA_ISM_FORMAT ) { - if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { ivas_ism_dec_digest_tc( st_ivas ); @@ -3129,6 +3110,7 @@ void ivas_jbm_dec_prepare_renderer( { num_objects = st_ivas->nchan_ism; } + for ( n = 0; n < num_objects; n++ ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) @@ -3153,6 +3135,7 @@ void ivas_jbm_dec_prepare_renderer( } } #ifdef OMASA_OBJECT_EDITING + if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { int16_t tcBufferSize; @@ -3160,9 +3143,9 @@ void ivas_jbm_dec_prepare_renderer( if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - for ( int16_t ch = 0; ch < 2; ch++ ) + for ( n = 0; n < BINAURAL_CHANNELS; n++ ) { - v_multc( st_ivas->hTcBuffer->tc[ch], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[ch], tcBufferSize ); + v_multc( st_ivas->hTcBuffer->tc[n], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[n], tcBufferSize ); } } } diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 8b26bfbaba..e192a4fe90 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1360,8 +1360,8 @@ void ivas_param_mc_dec_digest_tc( /* format converter */ int16_t channel_active[MAX_OUTPUT_CHANNELS]; IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; -#endif +#endif hParamMC = st_ivas->hParamMC; assert( hParamMC ); @@ -1588,6 +1588,7 @@ void ivas_param_mc_dec_digest_tc( return; } + #ifdef OBJ_EDITING_API /*------------------------------------------------------------------------- * ivas_param_mc_dec_prepare_renderer() @@ -1676,7 +1677,6 @@ void ivas_param_mc_dec_prepare_renderer( ivas_param_mc_dec_compute_interpolator( hParamMC->hMetadataPMC->bAttackPresent, hParamMC->hMetadataPMC->attackIndex, nCldfbSlots, hParamMC->h_output_synthesis_params.interpolator ); - #ifdef FIX_835_PARAMMC_BUFFER_VALUES /* loop over two bands at a time */ for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 77d89242a9..83f0aad084 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -171,6 +171,7 @@ ivas_error ivas_td_binaural_renderer_sf( c_indx++; } } + if ( subframe_idx == ism_md_subframe_update_jbm ) { #ifdef OBJ_EDITING_API @@ -178,6 +179,7 @@ ivas_error ivas_td_binaural_renderer_sf( { ISM_METADATA_FRAME ismMetaData[MAX_NUM_OBJECTS]; ISM_METADATA_HANDLE hIsmMetaData[MAX_NUM_OBJECTS]; + for ( nS = 0; nS < nchan_ism; nS++ ) { ismMetaData[nS].azimuth = st_ivas->hIsmMetaData[nS]->edited_azimuth; diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index 8164c2aa65..c788714599 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -772,6 +772,7 @@ void ivas_omasa_dirac_rend_jbm( for ( n = 0; n < st_ivas->nchan_ism; n++ ) { mvr2r( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); + #ifdef OMASA_OBJECT_EDITING /* Gain discrete objects, if edited */ if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) @@ -780,6 +781,7 @@ void ivas_omasa_dirac_rend_jbm( } #endif } + #ifdef OMASA_OBJECT_EDITING /* Gain MASA part, if edited */ if ( st_ivas->hMasaIsmData->masa_gain_is_edited ) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index eaf5d11a7e..7af10b9826 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -300,3 +300,56 @@ ivas_error ivas_osba_render_sf( return IVAS_ERR_OK; } + + +#ifdef OBJ_EDITING_API +/*-------------------------------------------------------------------------* + * ivas_osba_stereo_add_channels() + * + * + *-------------------------------------------------------------------------*/ + +void ivas_osba_stereo_add_channels( + float *tc_f[], /* i : transport channels */ + float *output_f[], /* i/o: output channels */ + const float gain, /* i : gain bed value */ + const int16_t nchan_out, /* i : number of output channels */ + const int16_t nchan_ism, /* i : number of ISM channels */ + const int16_t ism_mode, /* i : ISM mode */ + const int16_t n_samples_to_render /* i : output frame length per channel */ +) +{ + int16_t n; + + if ( ism_mode == ISM_SBA_MODE_DISC ) + { + if ( gain != 1.0f && gain >= 0.0f ) + { + int16_t i; + for ( n = 0; n < nchan_out; n++ ) + { + for ( i = 0; i < n_samples_to_render; i++ ) + { + output_f[n][i] += tc_f[n + nchan_ism][i] * gain; + } + } + } + else + { + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output_f[n], tc_f[n + nchan_ism], output_f[n], n_samples_to_render ); + } + } + } + else + { + for ( n = 0; n < nchan_out; n++ ) + { + v_add( output_f[n], tc_f[n + nchan_ism], output_f[n], n_samples_to_render ); + } + } + + return; +} +#endif diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 61ba65f590..181946512f 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -365,12 +365,14 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer ); } + #ifdef OBJ_EDITING_API if ( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); } #endif + free( *phIvasDec ); *phIvasDec = NULL; phIvasDec = NULL; @@ -549,6 +551,10 @@ ivas_error IVAS_DEC_Configure( if ( tsmEnabled && ( outputConfig == IVAS_AUDIO_CONFIG_BINAURAL || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) { hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); + if ( hIvasDec->flushbuffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); + } hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } @@ -834,11 +840,12 @@ ivas_error IVAS_DEC_FeedFrame_Serial( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t *serial, /* i : buffer containing serial input bitstream. Each bit should be stored as a single uint16_t value */ const uint16_t num_bits, /* i : number of bits in input bitstream */ - int16_t bfi /* i : bad frame indicator flag */ #ifdef OBJ_EDITING_API - , - int16_t isSplitRend, - ISAR_SPLIT_REND_BITS_DATA *splitRendBits + int16_t bfi, /* i : bad frame indicator flag */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +#else + int16_t bfi /* i : bad frame indicator flag */ #endif ) { @@ -1047,12 +1054,18 @@ ivas_error IVAS_DEC_FeedFrame_Serial( * * *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_GetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters /* o : object editing parameters handle */ +) { - ivas_error error; - int16_t dirac_read_idx; + int16_t dirac_read_idx, obj; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasEditableParameters == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || @@ -1072,7 +1085,6 @@ ivas_error IVAS_DEC_GetEditableParameters( { if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hIsmMetaData[obj]->azimuth; @@ -1083,6 +1095,7 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].gain = hIvasDec->st_ivas->hIsmMetaData[obj]->edited_gain; hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = hIvasDec->st_ivas->hIsmMetaData[obj]->non_diegetic_flag; } + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { hIvasEditableParameters->gain_bed = 1.0f; @@ -1090,7 +1103,6 @@ ivas_error IVAS_DEC_GetEditableParameters( } else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { hIvasEditableParameters->ism_metadata[obj].azimuth = hIvasDec->st_ivas->hParamIsmDec->azimuth_values[obj]; @@ -1102,17 +1114,17 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } } +#ifdef DEBUGGING else { assert( 0 && "This should never happen!" ); } +#endif } #ifdef OMASA_OBJECT_EDITING else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { /* object editing possible only in two highest OMASA modes */ - int16_t obj; - if ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { for ( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) @@ -1159,22 +1171,27 @@ ivas_error IVAS_DEC_GetEditableParameters( } #endif - error = IVAS_ERR_OK; - - return error; + return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_SetEditableParameters( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_SetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters /* i : object editing parameters handle */ +) { - ivas_error error; - int16_t dirac_read_idx; + int16_t dirac_read_idx, obj; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || @@ -1189,8 +1206,6 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - error = IVAS_ERR_OK; - #ifdef DEBUGGING assert( hIvasEditableParameters.num_obj == hIvasDec->st_ivas->nchan_ism ); #endif @@ -1199,7 +1214,6 @@ ivas_error IVAS_DEC_SetEditableParameters( { if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { hIvasDec->st_ivas->hIsmMetaData[obj]->edited_azimuth = hIvasEditableParameters.ism_metadata[obj].azimuth; @@ -1221,7 +1235,6 @@ ivas_error IVAS_DEC_SetEditableParameters( } else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) { - int16_t obj; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { #ifdef OBJ_EDITING_PARAMISM_BIN @@ -1251,6 +1264,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } #endif } + #ifdef OBJ_EDITING_PARAMISM_BIN /* MASA is not present with the ISM format */ hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; @@ -1264,8 +1278,7 @@ ivas_error IVAS_DEC_SetEditableParameters( #ifdef OMASA_OBJECT_EDITING else if ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) { - int16_t obj; - int32_t id_th; + int16_t id_th; float threshold_azi, threshold_ele; for ( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) @@ -1310,7 +1323,7 @@ ivas_error IVAS_DEC_SetEditableParameters( * which in turn depends from the object priority and importance: * importance -> priority -> number of bits -> elevation resolution -> elevation ring index -> azimuth resolution. * leading to elevation_resolution -> elevation threshold and azimuth resolution -> azimuth threshold */ - id_th = (int) ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); + id_th = (int16_t) ( fabsf( (float) hIvasDec->st_ivas->hMasaIsmData->elevation_ism[obj][dirac_read_idx] ) / delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3] + 0.5f ); threshold_azi = 360.0f / (float) no_phi_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 1][id_th]; threshold_ele = delta_theta_masa[hIvasDec->st_ivas->hMasaIsmData->bits_ism[obj] - 3]; @@ -1382,31 +1395,30 @@ ivas_error IVAS_DEC_SetEditableParameters( } #endif - return error; + return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_PrepareRenderer( ) * * Main function to decode to PCM data *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_PrepareRenderer( IVAS_DEC_HANDLE hIvasDec ) { - ivas_error error; - - error = IVAS_ERR_OK; - if ( hIvasDec == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); + hIvasDec->hasBeenPreparedRendering = true; - return error; -} + return IVAS_ERR_OK; +} #endif @@ -1445,7 +1457,6 @@ ivas_error IVAS_DEC_GetSamples( nTransportChannels = 0; #endif - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -1519,9 +1530,9 @@ ivas_error IVAS_DEC_GetSamples( } } #endif +#ifndef OBJ_EDITING_API { /* check if we need to run the setup function, tc decoding and feeding the renderer */ -#ifndef OBJ_EDITING_API if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { int16_t nResidualSamples, nSamplesTcsScaled; @@ -1584,34 +1595,34 @@ ivas_error IVAS_DEC_GetSamples( hIvasDec->hasBeenFedFrame = false; } #else - nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; - hIvasDec->hasBeenFedFrame = false; - /* check for possible flushed samples from a rate switch */ - if ( hIvasDec->nSamplesFlushed > 0 ) - { - void *pPcmBuffer; + nOutChannels = (uint8_t) hIvasDec->st_ivas->hDecoderConfig->nchan_out; + hIvasDec->hasBeenFedFrame = false; + /* check for possible flushed samples from a rate switch */ + if ( hIvasDec->nSamplesFlushed > 0 ) + { + void *pPcmBuffer; #ifdef DEBUGGING - assert( hIvasDec->pcmType == pcmType ); + assert( hIvasDec->pcmType == pcmType ); #endif - pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); - if ( pcmType == IVAS_DEC_PCM_INT16 ) - { - mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); - } - else if ( pcmType == IVAS_DEC_PCM_FLOAT ) - { - mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); - } + pPcmBuffer = pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ); + if ( pcmType == IVAS_DEC_PCM_INT16 ) + { + mvs2s( (int16_t *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); + } + else if ( pcmType == IVAS_DEC_PCM_FLOAT ) + { + mvr2r( (float *) hIvasDec->flushbuffer, pPcmBuffer, hIvasDec->nSamplesFlushed * nOutChannels ); + } #ifdef DEBUGGING - else - { - assert( 0 & "wrong PCM type for the flush buffer!" ); - } -#endif - nSamplesRendered += hIvasDec->nSamplesFlushed; - hIvasDec->nSamplesFlushed = 0; + else + { + assert( 0 & "wrong PCM type for the flush buffer!" ); } #endif + nSamplesRendered += hIvasDec->nSamplesFlushed; + hIvasDec->nSamplesFlushed = 0; + } +#endif /* render IVAS frames directly to the output buffer */ nSamplesToRender = nSamplesAsked - nSamplesRendered; @@ -1631,7 +1642,9 @@ ivas_error IVAS_DEC_GetSamples( { *needNewFrame = false; } +#ifndef OBJ_EDITING_API } +#endif } *nOutSamples = nSamplesRendered; @@ -1688,8 +1701,8 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { return error; } -#endif +#endif numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; #ifdef OBJ_EDITING_API @@ -1697,6 +1710,10 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( if ( hIvasDec->flushbuffer == NULL ) { hIvasDec->flushbuffer = (void *) malloc( numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( float ) ); + if ( hIvasDec->flushbuffer == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); + } hIvasDec->pcmType = IVAS_DEC_PCM_FLOAT; set_zero( (float *) hIvasDec->flushbuffer, numPoses * BINAURAL_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); } @@ -2293,7 +2310,6 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = hIsmMeta->edited_gain; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } -#ifdef OBJ_EDITING_API else if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { metadata->azimuth = st_ivas->hParamIsmDec->edited_azimuth_values[objectIdx]; @@ -2305,7 +2321,6 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->gainFactor = 1.f; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } -#endif else if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { metadata->azimuth = st_ivas->hIsmMetaData[objectIdx]->edited_azimuth; @@ -3192,20 +3207,27 @@ ivas_error IVAS_DEC_TSM_SetQuality( *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_VoIP_GetSamples( - IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ - uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ - const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ - void *pcmBuf, /* o : output synthesis signal */ + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ + const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ + void *pcmBuf, /* o : output synthesis signal */ +#ifdef OBJ_EDITING_API + const uint32_t systemTimestamp_ms, /* i : current system timestamp */ +#ifdef SUPPORT_JBM_TRACEFILE + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, +#endif +#ifdef OBJ_EDITING_API + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing // VE: parameter not really used... +#endif +#else const uint32_t systemTimestamp_ms /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE , JbmTraceFileWriterFn jbmWriterFn, void *jbmWriter #endif -#ifdef OBJ_EDITING_API - , - uint16_t *nSamplesRendered, - bool *parametersAvailableForEditing #endif ) { @@ -3316,14 +3338,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); - - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 -#if defined( OBJ_EDITING_API ) - , - 0, - 0 +#ifdef OBJ_EDITING_API + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0, 0, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -3331,13 +3350,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( else if ( hIvasDec->hasDecodedFirstGoodFrame ) { /* Decoder has been initialized with first good frame - do PLC */ - if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 -#if defined( OBJ_EDITING_API ) - , - 0, - 0 +#ifdef OBJ_EDITING_API + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1, 0, 0 ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ) != IVAS_ERR_OK ) #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -3376,8 +3393,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; hIvasDec->nSamplesRendered = 0; } + #ifdef OBJ_EDITING_API - /* :TODO: only return here if we really have editing initialized */ + /* :TODO: only return here if we really have editing initialized */ // VE: please address if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) { *parametersAvailableForEditing = true; @@ -3418,7 +3436,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* check if we still need to prepare the renderer */ if ( hIvasDec->hasBeenPreparedRendering == false ) { - if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) { return error; diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index dafae6518e..d5100de680 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -149,23 +149,24 @@ ivas_error IVAS_DEC_FeedFrame_Serial( IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ uint16_t *serial, /* i : buffer containing serial input bitstream. Each bit should be stored as a single uint16_t value */ const uint16_t num_bits, /* i : number of bits in input bitstream */ +#ifdef OBJ_EDITING_API + int16_t bfi, /* i : bad frame indicator flag */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +#else int16_t bfi /* i : bad frame indicator flag */ -#if defined( OBJ_EDITING_API ) - , - int16_t isSplitRend, - ISAR_SPLIT_REND_BITS_DATA *splitRendBits #endif ); #ifdef OBJ_EDITING_API ivas_error IVAS_DEC_GetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_EDITABLE_PARAMETERS *hIvasEditableParameters /* o : object editing parameters handle */ ); ivas_error IVAS_DEC_SetEditableParameters( - IVAS_DEC_HANDLE hIvasDec, - IVAS_EDITABLE_PARAMETERS hIvasEditableParameters + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + IVAS_EDITABLE_PARAMETERS hIvasEditableParameters /* i : object editing parameters handle */ ); ivas_error IVAS_DEC_PrepareRenderer( @@ -299,15 +300,23 @@ ivas_error IVAS_DEC_VoIP_GetSamples( uint16_t nSamplesPerChannel, /* i : number of samples per channel requested to be written to output buffer */ const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ void *pcmBuf, /* o : output synthesis signal */ - const uint32_t systemTimestamp_ms /* i : current system timestamp */ +#ifdef OBJ_EDITING_API + const uint32_t systemTimestamp_ms, /* i : current system timestamp */ #ifdef SUPPORT_JBM_TRACEFILE - , JbmTraceFileWriterFn jbmWriterFn, - void* jbmWriter + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, #endif #ifdef OBJ_EDITING_API - , - uint16_t *nSamplesRendered, - bool *parametersAvailableForEditing + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing // VE: arameter not really used... +#endif +#else + const uint32_t systemTimestamp_ms /* i : current system timestamp */ +#ifdef SUPPORT_JBM_TRACEFILE + , + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter +#endif #endif ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 19f6c7e554..616759626a 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1214,6 +1214,7 @@ static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices( uint16_t ismDirIndex; ismDirIndex = dirIndex - hSpatParamRendCom->numParametricDirections; assert( hMasaIsmData != NULL && "hMasaIsmData should not be NULL if we use it" ); + #ifdef OMASA_OBJECT_EDITING if ( hMasaIsmData->ism_dir_is_edited[ismDirIndex] ) { @@ -2983,7 +2984,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( float masaEneThisCh[2]; float ratioAccNewDivisor; - gainMasaPow2 = 1.0f; if ( masaGainEdited ) { @@ -3017,6 +3017,7 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( panGainsOut[ismDirIndex][ch] = panGainsIn[ismDirIndex][ch]; } } + /* Determine pan enes */ for ( ch = 0; ch < 2; ch++ ) { diff --git a/lib_rend/ivas_objectRenderer.c b/lib_rend/ivas_objectRenderer.c index dbe5cc8d06..4b1c5764b7 100644 --- a/lib_rend/ivas_objectRenderer.c +++ b/lib_rend/ivas_objectRenderer.c @@ -552,6 +552,7 @@ ivas_error TDREND_Update_object_positions( { return error; } + #ifdef OBJ_EDITING_INTERFACE if ( ( error = TDREND_MIX_SRC_SetGain( hBinRendererTd, nS, hIsmMetaData[nS]->gain ) ) != IVAS_ERR_OK ) { diff --git a/lib_rend/ivas_objectRenderer_sources.c b/lib_rend/ivas_objectRenderer_sources.c index 4f570e6182..6079f93b5b 100644 --- a/lib_rend/ivas_objectRenderer_sources.c +++ b/lib_rend/ivas_objectRenderer_sources.c @@ -106,7 +106,7 @@ ivas_error TDREND_MIX_SRC_SetPos( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetDir( - 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 : Direction vector */ ) @@ -132,17 +132,18 @@ ivas_error TDREND_MIX_SRC_SetDir( return IVAS_ERR_OK; } + #ifdef OBJ_EDITING_INTERFACE /*-------------------------------------------------------------------* - * TDREND_MIX_SRC_SetSourceGain() + * TDREND_MIX_SRC_SetGain() * * Set source gain --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetGain( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float Gain /* i : Gain */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float Gain /* i : Gain */ ) { TDREND_SRC_SPATIAL_SetGain( hBinRendererTd->Sources[SrcInd], Gain ); @@ -151,6 +152,7 @@ ivas_error TDREND_MIX_SRC_SetGain( } #endif + /*-------------------------------------------------------------------* * TDREND_MIX_SRC_SetDirAtten() * @@ -158,7 +160,7 @@ ivas_error TDREND_MIX_SRC_SetGain( --------------------------------------------------------------------*/ ivas_error TDREND_MIX_SRC_SetDirAtten( - 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 TDREND_DirAtten_t *DirAtten_p /* i : Directional attenuation specifier */ ) @@ -570,9 +572,12 @@ static void TDREND_SRC_SPATIAL_SetGain( ) { Src_p->SrcRend_p->SrcGain_p[0] = Gain; + + return; } #endif + /*-------------------------------------------------------------------* * TDREND_SRC_SPATIAL_GetDirGain() * diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index 8e6980b054..7203216338 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -722,9 +722,9 @@ ivas_error TDREND_MIX_SRC_SetDir( #ifdef OBJ_EDITING_INTERFACE ivas_error TDREND_MIX_SRC_SetGain( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float Gain /* i : Gain */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float Gain /* i : Gain */ ); #endif @@ -746,9 +746,9 @@ ivas_error TDREND_MIX_SRC_SetPlayState( #ifdef OBJ_EDITING_API ivas_error TDREND_MIX_SRC_SetSrcGain( - BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ - const int16_t SrcInd, /* i : Source index */ - const float SrcGain_p /* i : Source gain */ + BINAURAL_TD_OBJECT_RENDERER_HANDLE hBinRendererTd, /* i/o: TD renderer handle */ + const int16_t SrcInd, /* i : Source index */ + const float SrcGain_p /* i : Source gain */ ); #endif -- GitLab From db50fd50b0daa1f3541ece9efbcb16d7e03ffa05 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 9 Sep 2024 12:10:30 +0200 Subject: [PATCH 02/18] add sanity check for using objects editing; define related API error; print-out an info when objects editing is enabled --- apps/decoder.c | 11 ++++++++--- lib_com/ivas_error.h | 7 +++++++ lib_dec/ivas_init_dec.c | 9 +++++++++ lib_dec/ivas_stat_dec.h | 3 +++ lib_dec/lib_dec.c | 20 ++++++++++++++++++-- lib_dec/lib_dec.h | 5 ++++- readme.txt | 16 ++++++++-------- 7 files changed, 57 insertions(+), 14 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 72dbf89e16..06f8469749 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -432,8 +432,13 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#ifdef OBJ_EDITING_EXAMPLE + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, + arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nConfigure failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -1768,13 +1773,13 @@ static void usage_dec( void ) fprintf( stdout, "-aeid ID | File : Acoustic environment ID (number > 0)\n" ); fprintf( stdout, " alternatively, it can be a text file where each line contains \"ID duration\"\n" ); fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration.\n" ); +#ifdef OMASA_OBJECT_EDITING + fprintf( stdout, "-obj_edit : Enable objects editing\n" ); +#endif fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); fprintf( stdout, " Currently, all values default to level 3 (full functionality).\n" ); fprintf( stdout, "-q : Quiet mode, no frame counter\n" ); fprintf( stdout, " default is deactivated\n" ); -#ifdef OMASA_OBJECT_EDITING - fprintf( stdout, "-obj_edit : enable object editing\n" ); -#endif #ifdef DEBUG_MODE_INFO #ifdef DEBUG_MODE_INFO_TWEAK fprintf( stdout, "-info : specify subfolder name for debug output\n" ); diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 11727c4e5d..905be753a5 100644 --- a/lib_com/ivas_error.h +++ b/lib_com/ivas_error.h @@ -77,6 +77,9 @@ typedef enum IVAS_ERR_EXT_ORIENTATION_NOT_SUPPORTED, IVAS_ERR_DIRECTIVITY_NOT_SUPPORTED, IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED, +#ifdef OBJ_EDITING_API + IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED, +#endif IVAS_ERR_INVALID_HRTF, IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA, IVAS_ERR_INVALID_INPUT_FORMAT, @@ -254,6 +257,10 @@ static inline const char *ivas_error_to_string( ivas_error error_code ) return "Directivity not supported"; case IVAS_ERR_ACOUSTIC_ENVIRONMENT_NOT_SUPPORTED: return "Acoustic environment not supported"; +#ifdef OBJ_EDITING_API + case IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED: + return "Objects editing not supported"; +#endif case IVAS_ERR_INVALID_HRTF: return "Unsupported HRTF filter set"; case IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA: diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index edd3ed644e..d450512c65 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2922,6 +2922,15 @@ static ivas_error doSanityChecks_IVAS( } } +#ifdef OBJ_EDITING_API + if ( st_ivas->hDecoderConfig->Opt_ObjEdit_on ) + { + if ( !( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) ) + { + return IVAS_ERROR( IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED, "Wrong set-up: Obect editing is not supported in this IVAS format." ); + } + } +#endif #ifdef DEBUGGING if ( ( st_ivas->hDecoderConfig->force_rend == FORCE_TD_RENDERER ) && ( ( st_ivas->ivas_format != MC_FORMAT && st_ivas->ivas_format != ISM_FORMAT ) || ( output_config != IVAS_AUDIO_CONFIG_BINAURAL && output_config != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM ) || ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode != MC_MODE_MCT ) ) ) { diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index c7d03b3fc2..870e73b4c8 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1030,6 +1030,9 @@ typedef struct decoder_config_structure int16_t Opt_ExternalOrientation; /* indicates whether external orientations are used */ int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ +#ifdef OBJ_EDITING_API + int16_t Opt_ObjEdit_on; /* indicates whether object editing option is used */ +#endif #ifdef DEBUGGING /* temp. development parameters */ int16_t force_rend; /* forced TD/CLDFB binaural renderer (for ISM and MC) */ diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 95fc781f18..eced36aedb 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -323,6 +323,9 @@ static void init_decoder_config( hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; hDecoderConfig->Opt_aeid_on = 0; +#ifdef OBJ_EDITING_API + hDecoderConfig->Opt_ObjEdit_on = 0; +#endif return; } @@ -439,7 +442,10 @@ ivas_error IVAS_DEC_Configure( const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ - const bool delayCompensationEnabled /* i : enable delay compensation */ +#ifdef OBJ_EDITING_API + const bool objEditEnabled, /* i : enable object editing */ +#endif + const bool delayCompensationEnabled /* i : enable delay compensation */ ) { Decoder_Struct *st_ivas; @@ -498,6 +504,9 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; hDecoderConfig->Opt_dpid_on = (int16_t) dpidEnabled; hDecoderConfig->Opt_aeid_on = acousticEnvironmentId != 65535 ? TRUE : FALSE; +#ifdef OBJ_EDITING_API + hDecoderConfig->Opt_ObjEdit_on = (int16_t) objEditEnabled; +#endif if ( renderFramesize == IVAS_RENDER_FRAMESIZE_UNKNOWN ) { @@ -1071,7 +1080,7 @@ ivas_error IVAS_DEC_GetEditableParameters( ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) { - return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); + return IVAS_ERROR( IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED, "Object editing is not supported in this operation mode." ); } if ( hIvasEditableParameters == NULL || hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -3929,6 +3938,13 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Acoustic environment ID:ON\n" ); } +#ifdef OBJ_EDITING_API + + if ( st_ivas->hDecoderConfig->Opt_ObjEdit_on ) + { + fprintf( stdout, "Objects editing : ON\n" ); + } +#endif } /*-----------------------------------------------------------------* diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index d5100de680..70bd5bf2f5 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -123,7 +123,7 @@ ivas_error IVAS_DEC_Configure( const uint32_t sampleRate, /* i : output sampling frequency */ const IVAS_AUDIO_CONFIG outputConfig, /* i : audio configuration */ const bool tsmEnabled, /* i : enable TSM */ - const IVAS_RENDER_FRAMESIZE renderFramesize, /* i : rendering frame size */ + const IVAS_RENDER_FRAMESIZE renderFramesize,/* i : rendering frame size */ const bool customLsOutputEnabled, /* i : enable custom loudspeaker setup handle */ const bool hrtfReaderEnabled, /* i : enable HRTF binary file input */ const bool enableHeadRotation, /* i : enable head rotation for binaural output */ @@ -134,6 +134,9 @@ ivas_error IVAS_DEC_Configure( const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ +#ifdef OBJ_EDITING_API + const bool objEditEnabled, /* i : enable object editing */ +#endif const bool delayCompensationEnabled /* i : enable delay compensation */ ); diff --git a/readme.txt b/readme.txt index cd5a01d4be..0cbfe24199 100644 --- a/readme.txt +++ b/readme.txt @@ -242,8 +242,8 @@ Usage for IVAS: IVAS_dec.exe [Options] OutputConf Fs bitstream_file output_file Mandatory parameters: --------------------- OutputConf : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA, - HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, - BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT + HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, + BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT By default, channel order and loudspeaker positions are equal to the encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker layout file. See below for details. @@ -271,7 +271,7 @@ Options: Format files, the magic word in the mime file is used to determine which of the two supported formats is in use. default bitstream file format is G.192 --fr L : render frame size in ms L=(5,10,20), default is 20 +-fr L : render frame size in ms L=(5,10,20), default is 20 -hrtf File : HRTF filter File used in BINAURAL rendering -T File : Head rotation specified by external trajectory File -otr tracking_type : Head orientation tracking type: 'none', 'ref', 'avg', 'ref_vec' @@ -287,8 +287,9 @@ Options: -dpid ID : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration -aeid ID | File : Acoustic environment ID (number > 0) or - alternatively, it can be a text file where each line contains "ID duration" - for BINAURAL_ROOM_REVERB output configuration. + alternatively, it can be a text file where each line contains "ID duration" + for BINAURAL_ROOM_REVERB output configuration. +-obj_edit : Enable objects editing -level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. -om File : Coded metadata File for BINAURAL_SPLIT_PCM OutputConf Currently, all values default to level 3 (full functionality). @@ -309,7 +310,7 @@ Options: -of Format : Audio Format of output file Alternatively, it can be a custom loudspeaker layout File -fs : Input sampling rate in kHz (16, 32, 48) - required only with raw PCM inputs --fr L : render frame size in ms L=(5,10,20), default is 20 +-fr L : render frame size in ms L=(5,10,20), default is 20 -hrtf File : Custom HRTF File for binaural rendering (only for binaural outputs) -T File : Head rotation trajectory File for simulation of head tracking (only for binaural outputs) -otr tracking_type : Head orientation tracking type: 'none', 'ref', 'avg' or `ref_vec` or `ref_vec_lev` (only for binaural outputs) @@ -322,8 +323,7 @@ Options: -dpid ID : Directivity pattern ID(s) (space-separated list of up to 4 numbers can be specified) for binaural output configuration -aeid ID | File : Acoustic environment ID (number > 0) - alternatively, it can be a text file where each line contains "ID duration" - for BINAURAL_ROOM_REVERB output configuration. + alternatively, it can be a text file where each line contains "ID duration" for BINAURAL_ROOM_REVERB output configuration. -lp Position : Output LFE position. Comma-delimited triplet of [gain, azimuth, elevation] where gain is linear (like --gain, -g) and azimuth, elevation are in degrees. If specified, overrides the default behavior which attempts to map input to output LFE channel(s) -- GitLab From eac9c9c255c7d58892366a60defdcc308ac52b5f Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 9 Sep 2024 12:16:02 +0200 Subject: [PATCH 03/18] clang-format --- lib_dec/ivas_osba_dec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index 7af10b9826..bb5f547beb 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -306,7 +306,7 @@ ivas_error ivas_osba_render_sf( /*-------------------------------------------------------------------------* * ivas_osba_stereo_add_channels() * - * + * *-------------------------------------------------------------------------*/ void ivas_osba_stereo_add_channels( -- GitLab From 57efd6536ca2197ff5fb5357e6aacffafe40cf08 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 9 Sep 2024 12:59:07 +0200 Subject: [PATCH 04/18] comments --- apps/decoder.c | 2 +- lib_dec/lib_dec.c | 2 +- lib_dec/lib_dec.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 06f8469749..4025fe31ad 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3386,7 +3386,7 @@ static ivas_error decodeVoIP( } #ifdef OBJ_EDITING_API - if ( parameterAvailableForEditing == true ) + if ( parameterAvailableForEditing == true ) // VE: harmonize it with decodeG192() { /* do the object editing here */ } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index eced36aedb..6cbc450ab9 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -3228,7 +3228,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif #ifdef OBJ_EDITING_API uint16_t *nSamplesRendered, /* o : number of samples rendered */ - bool *parametersAvailableForEditing // VE: parameter not really used... + bool *parametersAvailableForEditing /* o : indicates whether objects editing is available*/ #endif #else const uint32_t systemTimestamp_ms /* i : current system timestamp */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 70bd5bf2f5..bf165eb86e 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -311,7 +311,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #endif #ifdef OBJ_EDITING_API uint16_t *nSamplesRendered, /* o : number of samples rendered */ - bool *parametersAvailableForEditing // VE: arameter not really used... + bool *parametersAvailableForEditing /* o : indicates whether objects editing is available */ #endif #else const uint32_t systemTimestamp_ms /* i : current system timestamp */ -- GitLab From 5ec905e5ae9716bbaecba992606261e359fc6d39 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 10 Sep 2024 12:55:22 +0200 Subject: [PATCH 05/18] correct function description --- lib_dec/ivas_jbm_dec.c | 1 - lib_dec/lib_dec.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index 16569430bc..0724f6a7c7 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -3013,7 +3013,6 @@ void ivas_dec_prepare_renderer( } else if ( st_ivas->ivas_format == ISM_FORMAT ) { - /* Rendering */ if ( st_ivas->ism_mode == ISM_MODE_PARAM ) { if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC ) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 6cbc450ab9..b21761df8e 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1411,13 +1411,13 @@ ivas_error IVAS_DEC_SetEditableParameters( /*---------------------------------------------------------------------* * IVAS_DEC_PrepareRenderer( ) * - * prepare IVAS JBM renderer + * prepare IVAS renderer *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_PrepareRenderer( IVAS_DEC_HANDLE hIvasDec ) { - if ( hIvasDec == NULL ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } -- GitLab From d46c3e3b2a20a4aded2cf0065789976692544937 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 18 Sep 2024 10:58:09 +0200 Subject: [PATCH 06/18] introduce OBJ_EDITING_COMMANDLINE switch --- apps/decoder.c | 10 +++++----- lib_com/options.h | 1 + lib_dec/ivas_init_dec.c | 2 +- lib_dec/ivas_stat_dec.h | 2 +- lib_dec/lib_dec.c | 8 ++++---- lib_dec/lib_dec.h | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 4025fe31ad..a82677ac17 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -150,7 +150,7 @@ typedef struct AcousticEnvironmentSequence aeSequence; bool dpidEnabled; uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS]; -#ifdef OBJ_EDITING_EXAMPLE +#ifdef OBJ_EDITING_COMMANDLINE bool objEditEnabled; #endif @@ -432,7 +432,7 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; -#ifdef OBJ_EDITING_EXAMPLE +#ifdef OBJ_EDITING_COMMANDLINE if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, arg.tsmEnabled, arg.renderFramesize, arg.customLsOutputEnabled, arg.hrtfReaderEnabled, arg.enableHeadRotation, arg.enableExternalOrientation, arg.orientation_tracking, arg.renderConfigEnabled, arg.non_diegetic_pan_enabled, arg.non_diegetic_pan_gain, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) #else @@ -1109,7 +1109,7 @@ static bool parseCmdlIVAS_dec( arg->directivityPatternId[i] = 65535; } -#ifdef OBJ_EDITING_EXAMPLE +#ifdef OBJ_EDITING_COMMANDLINE arg->objEditEnabled = false; #endif @@ -1565,7 +1565,7 @@ static bool parseCmdlIVAS_dec( i += tmp; } -#ifdef OBJ_EDITING_EXAMPLE +#ifdef OBJ_EDITING_COMMANDLINE else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 ) { arg->objEditEnabled = true; @@ -1773,7 +1773,7 @@ static void usage_dec( void ) fprintf( stdout, "-aeid ID | File : Acoustic environment ID (number > 0)\n" ); fprintf( stdout, " alternatively, it can be a text file where each line contains \"ID duration\"\n" ); fprintf( stdout, " for BINAURAL_ROOM_REVERB output configuration.\n" ); -#ifdef OMASA_OBJECT_EDITING +#ifdef OBJ_EDITING_COMMANDLINE fprintf( stdout, "-obj_edit : Enable objects editing\n" ); #endif fprintf( stdout, "-level level : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" ); diff --git a/lib_com/options.h b/lib_com/options.h index ff1bc4ed7a..a4df05ee14 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -157,6 +157,7 @@ #define OBJ_EDITING_INTERFACE /* Interface for object editing */ #ifdef OBJ_EDITING_INTERFACE #define OBJ_EDITING_API /* object editing changes related to the API */ +#define OBJ_EDITING_COMMANDLINE /* obj editing command-line option */ #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ #define OMASA_OBJECT_EDITING /* Nokia: object editing interface for OMASA */ #define OBJ_EDITING_PARAMISM_BIN /* Nokia: object editing for ParamISM to binaural */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 1a498ff4d9..c7e71ab466 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2908,7 +2908,7 @@ static ivas_error doSanityChecks_IVAS( } } -#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_COMMANDLINE if ( st_ivas->hDecoderConfig->Opt_ObjEdit_on ) { if ( !( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) ) diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 1626607bf3..9ed05b1ae2 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1028,7 +1028,7 @@ typedef struct decoder_config_structure int16_t Opt_ExternalOrientation; /* indicates whether external orientations are used */ int16_t Opt_dpid_on; /* indicates whether Directivity pattern option is used */ int16_t Opt_aeid_on; /* indicates whether Acoustic environment option is used */ -#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_COMMANDLINE int16_t Opt_ObjEdit_on; /* indicates whether object editing option is used */ #endif #ifdef DEBUGGING diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 8dd23f0256..103b65c4e6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -323,7 +323,7 @@ static void init_decoder_config( hDecoderConfig->Opt_ExternalOrientation = 0; hDecoderConfig->Opt_dpid_on = 0; hDecoderConfig->Opt_aeid_on = 0; -#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_COMMANDLINE hDecoderConfig->Opt_ObjEdit_on = 0; #endif @@ -442,7 +442,7 @@ ivas_error IVAS_DEC_Configure( const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ -#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_COMMANDLINE const bool objEditEnabled, /* i : enable object editing */ #endif const bool delayCompensationEnabled /* i : enable delay compensation */ @@ -504,7 +504,7 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; hDecoderConfig->Opt_dpid_on = (int16_t) dpidEnabled; hDecoderConfig->Opt_aeid_on = acousticEnvironmentId != 65535 ? TRUE : FALSE; -#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_COMMANDLINE hDecoderConfig->Opt_ObjEdit_on = (int16_t) objEditEnabled; #endif @@ -3933,7 +3933,7 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Acoustic environment ID:ON\n" ); } -#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_COMMANDLINE if ( st_ivas->hDecoderConfig->Opt_ObjEdit_on ) { diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index bf165eb86e..b9804bada1 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -134,7 +134,7 @@ ivas_error IVAS_DEC_Configure( const float non_diegetic_pan_gain, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ const uint16_t acousticEnvironmentId, /* i : Acoustic environment ID */ -#ifdef OBJ_EDITING_API +#ifdef OBJ_EDITING_COMMANDLINE const bool objEditEnabled, /* i : enable object editing */ #endif const bool delayCompensationEnabled /* i : enable delay compensation */ -- GitLab From 979318d77c488c9f0f8390672b017c14fe8572c4 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 18 Sep 2024 11:32:48 +0200 Subject: [PATCH 07/18] add OBJ_EDITING_EXAMPLE to VoIP path --- apps/decoder.c | 149 +++++++++++++++++++++++++++++-------------------- 1 file changed, 90 insertions(+), 59 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index a82677ac17..b0a7413846 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -171,6 +171,10 @@ static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBs static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #endif +#ifdef OBJ_EDITING_EXAMPLE +static ivas_error do_object_editing( IVAS_DEC_HANDLE hIvasDec ); +#endif + /*------------------------------------------------------------------------------------------* * main() @@ -2459,76 +2463,25 @@ static ivas_error decodeG192( } #ifdef OBJ_EDITING_API -#ifdef OBJ_EDITING_EXAMPLE - /* Do object info editing */ if ( arg.objEditEnabled ) { - IVAS_EDITABLE_PARAMETERS editableParameters; - - /* get object parameters */ - if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - goto cleanup; - } - - /* edit object parameters...*/ - - /* put the objects equally spaced at the horizontal plane */ - /* and play a little bit with the gains... */ - int16_t obj_idx, non_diegetic_obj_idx; - int16_t num_nondiegetic_objects; - - num_nondiegetic_objects = 0; - for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) - { - if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) - { - num_nondiegetic_objects++; - } - } - - if ( num_nondiegetic_objects ) - { - float start_angle, angle_inc; - angle_inc = 360.0f / (float) num_nondiegetic_objects; - start_angle = angle_inc / 2.0f; - for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) - { - if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) - { - editableParameters.ism_metadata[obj_idx].elevation = 0.0f; - editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc; - non_diegetic_obj_idx++; - } - } - } - - /* breakover object gains */ - for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) - { - editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; - } - - editableParameters.gain_bed = 0.5f; - - /* set new object parameters */ - if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) + /* Do object metadata editing here */ +#ifdef OBJ_EDITING_EXAMPLE + if ( ( error = do_object_editing( hIvasDec ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#endif } -#endif /* Do the final preparations needed for rendering */ if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) { fprintf( stderr, "\nError: could not prepare the renderer: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } -#endif } +#endif if ( isSplitRend ) { @@ -3375,9 +3328,9 @@ static ivas_error decodeVoIP( #endif #else #ifdef OBJ_EDITING_API - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing & nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing & nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) #endif #endif { @@ -3388,7 +3341,12 @@ static ivas_error decodeVoIP( #ifdef OBJ_EDITING_API if ( parameterAvailableForEditing == true ) // VE: harmonize it with decodeG192() { - /* do the object editing here */ +#ifdef OBJ_EDITING_EXAMPLE + if ( ( error = do_object_editing( hIvasDec ) ) != IVAS_ERR_OK ) + { + goto cleanup; + } +#endif } } /* while ( nSamplesRendered < nOutSamples ) */ #endif @@ -3674,6 +3632,78 @@ cleanup: return error; } +#ifdef OBJ_EDITING_EXAMPLE + +/*---------------------------------------------------------------------* + * do_object_editing() + * + * Example function of how to edit objects metadata + *---------------------------------------------------------------------*/ + +static ivas_error do_object_editing( + IVAS_DEC_HANDLE hIvasDec ) +{ + IVAS_EDITABLE_PARAMETERS editableParameters; + ivas_error error; + + /* get object parameters */ + if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + return error; + } + + /* edit object parameters...*/ + + /* put the objects equally spaced at the horizontal plane */ + /* and play a little bit with the gains... */ + int16_t obj_idx, non_diegetic_obj_idx; + int16_t num_nondiegetic_objects; + + num_nondiegetic_objects = 0; + for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + { + num_nondiegetic_objects++; + } + } + + if ( num_nondiegetic_objects ) + { + float start_angle, angle_inc; + angle_inc = 360.0f / (float) num_nondiegetic_objects; + start_angle = angle_inc / 2.0f; + for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + { + editableParameters.ism_metadata[obj_idx].elevation = 0.0f; + editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc; + non_diegetic_obj_idx++; + } + } + } + + /* breakover object gains */ + for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + { + editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; + } + + editableParameters.gain_bed = 0.5f; + + /* set new object parameters */ + if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + return error; + } + + return IVAS_ERR_OK; +} + +#endif #ifdef DEBUGGING @@ -3699,4 +3729,5 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( } #endif + #undef WMC_TOOL_SKIP -- GitLab From 3e5f9c610a911681156f704d82ab97fa56cc146b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 18 Sep 2024 11:53:46 +0200 Subject: [PATCH 08/18] differentiate OBJ_EDITING_EXAMPLE and API support --- apps/decoder.c | 89 ++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index b0a7413846..810d1eacb2 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -172,7 +172,7 @@ static int16_t app_own_random( int16_t *seed ); static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec( char *forcedRendModeChar ); #endif #ifdef OBJ_EDITING_EXAMPLE -static ivas_error do_object_editing( IVAS_DEC_HANDLE hIvasDec ); +static void do_object_editing( IVAS_EDITABLE_PARAMETERS *editableParameters ); #endif @@ -2463,15 +2463,29 @@ static ivas_error decodeG192( } #ifdef OBJ_EDITING_API + /* Object metadata editing */ if ( arg.objEditEnabled ) { - /* Do object metadata editing here */ -#ifdef OBJ_EDITING_EXAMPLE - if ( ( error = do_object_editing( hIvasDec ) ) != IVAS_ERR_OK ) + IVAS_EDITABLE_PARAMETERS editableParameters; + + /* get object parameters */ + if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) { - goto cleanup; + fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + return error; } + + /* Do object metadata editing here ... */ +#ifdef OBJ_EDITING_EXAMPLE + do_object_editing( &editableParameters ); + #endif + /* set new object parameters */ + if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + return error; + } } /* Do the final preparations needed for rendering */ @@ -3339,14 +3353,29 @@ static ivas_error decodeVoIP( } #ifdef OBJ_EDITING_API + /* Object metadata editing */ if ( parameterAvailableForEditing == true ) // VE: harmonize it with decodeG192() { -#ifdef OBJ_EDITING_EXAMPLE - if ( ( error = do_object_editing( hIvasDec ) ) != IVAS_ERR_OK ) + IVAS_EDITABLE_PARAMETERS editableParameters; + + /* get object parameters */ + if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) { - goto cleanup; + fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + return error; } + + /* Do object metadata editing here ... */ +#ifdef OBJ_EDITING_EXAMPLE + do_object_editing( &editableParameters ); + #endif + /* set new object parameters */ + if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); + return error; + } } } /* while ( nSamplesRendered < nOutSamples ) */ #endif @@ -3637,33 +3666,21 @@ cleanup: /*---------------------------------------------------------------------* * do_object_editing() * - * Example function of how to edit objects metadata + * Example function to edit objects parameters *---------------------------------------------------------------------*/ -static ivas_error do_object_editing( - IVAS_DEC_HANDLE hIvasDec ) +static void do_object_editing( + IVAS_EDITABLE_PARAMETERS *editableParameters ) { - IVAS_EDITABLE_PARAMETERS editableParameters; - ivas_error error; - - /* get object parameters */ - if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - return error; - } - - /* edit object parameters...*/ - /* put the objects equally spaced at the horizontal plane */ /* and play a little bit with the gains... */ int16_t obj_idx, non_diegetic_obj_idx; int16_t num_nondiegetic_objects; num_nondiegetic_objects = 0; - for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + for ( obj_idx = 0; obj_idx < editableParameters->num_obj; obj_idx++ ) { - if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + if ( !editableParameters->ism_metadata[obj_idx].non_diegetic_flag ) { num_nondiegetic_objects++; } @@ -3674,33 +3691,27 @@ static ivas_error do_object_editing( float start_angle, angle_inc; angle_inc = 360.0f / (float) num_nondiegetic_objects; start_angle = angle_inc / 2.0f; - for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters->num_obj; obj_idx++ ) { - if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag ) + if ( !editableParameters->ism_metadata[obj_idx].non_diegetic_flag ) { - editableParameters.ism_metadata[obj_idx].elevation = 0.0f; - editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc; + editableParameters->ism_metadata[obj_idx].elevation = 0.0f; + editableParameters->ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc; non_diegetic_obj_idx++; } } } /* breakover object gains */ - for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ ) + for ( obj_idx = 0; obj_idx < editableParameters->num_obj; obj_idx++ ) { - editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; + editableParameters->ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f; } - editableParameters.gain_bed = 0.5f; + editableParameters->gain_bed = 0.5f; - /* set new object parameters */ - if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) - { - fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); - return error; - } - return IVAS_ERR_OK; + return; } #endif -- GitLab From 4b98829e55d431f07344d60b333bc91bd22b4c7a Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 18 Sep 2024 12:29:14 +0200 Subject: [PATCH 09/18] Make clear separation between decoding and rendering: functions IVAS_DEC_GetSamplesDecoder() and IVAS_DEC_GetSamplesRenderer() now replaced function IVAS_DEC_GetSamples() --- apps/decoder.c | 18 ++- lib_dec/lib_dec.c | 287 +++++++++++++++++++++++++++------------------- lib_dec/lib_dec.h | 13 +++ 3 files changed, 195 insertions(+), 123 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 810d1eacb2..587447bd1e 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -2451,10 +2451,11 @@ static ivas_error decodeG192( } } #endif - /* Feed into decoder */ #ifdef OBJ_EDITING_API + /* Feed into decoder and decode transport channels */ if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) #else + /* Feed into decoder */ if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi ) ) != IVAS_ERR_OK ) #endif { @@ -2497,6 +2498,7 @@ static ivas_error decodeG192( } #endif + /* Render */ if ( isSplitRend ) { if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) @@ -2510,14 +2512,24 @@ static ivas_error decodeG192( } else { - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) +#ifdef OBJ_EDITING_API + if ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) { - fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + fprintf( stderr, "\nError in IVAS_DEC_GetSamplesRenderer(): %s\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; } +#else + if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) + { + fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); + goto cleanup; + } +#endif + nSamplesRendered += nSamplesRendered_loop; nSamplesToRender -= nSamplesRendered_loop; } + if ( needNewFrame ) { frame++; diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 103b65c4e6..3f18a9aa76 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -926,128 +926,13 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; #ifdef OBJ_EDITING_API - /* Decode TCs, do TSM and feed to renderer. - If TSM is generally enabled, we have to wait for the first good frame. - Otherwise, we directly decode the first frame in any case. - */ - if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + /* Decode TCs, do TSM and feed to renderer */; + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) { - uint16_t l_ts, nTimeScalerOutSamples; - uint8_t nTransportChannels, nOutChannels; - int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; - - if ( isSplitRend ) - { - if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->pcmType, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) - { - if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) - { - return error; - } - } - - /* IVAS TC decoder */ - if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) - { - return error; - } - - /* JBM */ - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - - assert( nTimeScalerOutSamples <= APA_BUF ); - nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; - hIvasDec->timeScalingDone = 1; - } - else - { - nSamplesTcsScaled = hIvasDec->nSamplesFrame; - } - - /* Feed decoded transport channels samples to the renderer */ - if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) - { - return error; - } - - if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) - { - /* feed residual samples to TSM for the next call */ - if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) - { - return IVAS_ERR_UNKNOWN; - } - } - hIvasDec->hasBeenFedFrame = false; - } - hIvasDec->hasBeenPreparedRendering = false; - - if ( hIvasDec->st_ivas->hIsmMetaData[0] ) - { - if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) - { -#ifdef OMASA_OBJECT_EDITING - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#else - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) -#endif - { - int16_t obj; - ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) - { - hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; - hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; - hIsmMetaData[obj]->edited_yaw = hIsmMetaData[obj]->yaw; - hIsmMetaData[obj]->edited_pitch = hIsmMetaData[obj]->pitch; - hIsmMetaData[obj]->edited_radius = hIsmMetaData[obj]->radius; - hIsmMetaData[obj]->edited_gain = 1.0f; - } - - if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) - { - hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; - } - } - } + return error; } - if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) - { - if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) - { - int16_t obj = 0; - PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; - for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) - { - hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; - hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; - } - } - } #endif - return IVAS_ERR_OK; } @@ -1426,6 +1311,158 @@ ivas_error IVAS_DEC_PrepareRenderer( #endif +#ifdef OBJ_EDITING_API + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSamplesDecoder( ) + * + * Main function to decode transport channels, do TSM and feed to renderer. + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetSamplesDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +) +{ + ivas_error error; + + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + + /* If TSM is generally enabled, we have to wait for the first good frame. + Otherwise, we directly decode the first frame in any case. */ + if ( ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && hIvasDec->hasBeenFedFirstGoodFrame ) || !hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + uint16_t l_ts, nTimeScalerOutSamples; + uint8_t nTransportChannels, nOutChannels; + int16_t nResidualSamples, nSamplesTcsScaled, nOutSamplesElse; + + if ( isSplitRend ) + { + if ( ( error = isar_set_split_rend_setup( hIvasDec->st_ivas->hSplitBinRend, &hIvasDec->st_ivas->hRenderConfig->split_rend_config, hIvasDec->st_ivas->hCombinedOrientationData, splitRendBits ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + if ( ( error = IVAS_DEC_Setup( hIvasDec, &l_ts, &nTransportChannels, &nOutChannels, &hIvasDec->nSamplesFlushed, hIvasDec->pcmType, hIvasDec->flushbuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm && nTransportChannels != hIvasDec->nTransportChannelsOld ) + { + if ( ( error = IVAS_DEC_VoIP_reconfigure( hIvasDec, nTransportChannels, l_ts ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* IVAS TC decoder */ + if ( ( error = IVAS_DEC_GetTcSamples( hIvasDec, hIvasDec->apaExecBuffer, &nOutSamplesElse ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* JBM */ + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + if ( apa_set_scale( hIvasDec->hTimeScaler, hIvasDec->tsm_scale ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + if ( apa_exec( hIvasDec->hTimeScaler, hIvasDec->apaExecBuffer, hIvasDec->nSamplesFrame * nTransportChannels, (uint16_t) hIvasDec->tsm_max_scaling, hIvasDec->apaExecBuffer, &nTimeScalerOutSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + + assert( nTimeScalerOutSamples <= APA_BUF ); + nSamplesTcsScaled = nTimeScalerOutSamples / nTransportChannels; + hIvasDec->timeScalingDone = 1; + } + else + { + nSamplesTcsScaled = hIvasDec->nSamplesFrame; + } + + /* Feed decoded transport channels samples to the renderer */ + if ( ( error = IVAS_DEC_RendererFeedTcSamples( hIvasDec, nSamplesTcsScaled, &nResidualSamples, hIvasDec->apaExecBuffer ) ) != IVAS_ERR_OK ) + { + return error; + } + + if ( hIvasDec->st_ivas->hDecoderConfig->Opt_tsm ) + { + /* feed residual samples to TSM for the next call */ + if ( apa_set_renderer_residual_samples( hIvasDec->hTimeScaler, (uint16_t) nResidualSamples ) != 0 ) + { + return IVAS_ERR_UNKNOWN; + } + } + hIvasDec->hasBeenFedFrame = false; + } + hIvasDec->hasBeenPreparedRendering = false; + + if ( hIvasDec->st_ivas->hIsmMetaData[0] ) + { + if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) + { +#ifdef OMASA_OBJECT_EDITING + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#else + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC || hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) +#endif + { + int16_t obj; + ISM_METADATA_HANDLE *hIsmMetaData = hIvasDec->st_ivas->hIsmMetaData; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + { + hIsmMetaData[obj]->edited_azimuth = hIsmMetaData[obj]->azimuth; + hIsmMetaData[obj]->edited_elevation = hIsmMetaData[obj]->elevation; + hIsmMetaData[obj]->edited_yaw = hIsmMetaData[obj]->yaw; + hIsmMetaData[obj]->edited_pitch = hIsmMetaData[obj]->pitch; + hIsmMetaData[obj]->edited_radius = hIsmMetaData[obj]->radius; + hIsmMetaData[obj]->edited_gain = 1.0f; + } + + if ( hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + hIvasDec->st_ivas->hSbaIsmData->gain_bed = 1.0f; + } + } + } + } + + if ( hIvasDec->st_ivas->hParamIsmDec != NULL ) + { + if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_PARAM ) + { + int16_t obj = 0; + PARAM_ISM_DEC_HANDLE hParamIsmDec = hIvasDec->st_ivas->hParamIsmDec; + for ( obj = 0; obj < hIvasDec->st_ivas->nchan_ism; obj++ ) + { + hParamIsmDec->edited_azimuth_values[obj] = hParamIsmDec->azimuth_values[obj]; + hParamIsmDec->edited_elevation_values[obj] = hParamIsmDec->elevation_values[obj]; + } + } + } + + return IVAS_ERR_OK; +} + + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSamplesRenderer( ) + * + * Main function to render the decoded data to output data + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetSamplesRenderer( +#else /*---------------------------------------------------------------------* * IVAS_DEC_GetSamples( ) * @@ -1434,6 +1471,7 @@ ivas_error IVAS_DEC_PrepareRenderer( ivas_error IVAS_DEC_GetSamples( +#endif IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ @@ -1753,11 +1791,19 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( } } +#ifdef OBJ_EDITING_API + /* render */ + if ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) + { + return error; + } +#else /* Decode and render */ if ( ( error = IVAS_DEC_GetSamples( hIvasDec, numSamplesPerChannelToDecode, IVAS_DEC_PCM_FLOAT, pcmBuf, nOutSamples, needNewFrame ) ) != IVAS_ERR_OK ) { return error; } +#endif /* change buffer layout */ for ( i = 0; i < numSamplesPerChannelToDecode; ++i ) @@ -3343,6 +3389,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( bsCompactToSerial( dataUnit->data, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize ); #ifdef OBJ_EDITING_API + /* Feed into decoder and decode transport channels */ if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0, 0, 0 ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) @@ -3447,9 +3494,9 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #endif - /* render IVAS frames directly to the output buffer */ + /* render IVAS frames directly to the output buffer */ #ifdef OBJ_EDITING_API - if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_GetSamplesRenderer( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, *nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, pcmType, pcm_buffer_offset( pcmBuf, pcmType, nSamplesRendered * nOutChannels ), &nSamplesRendered_loop, &tmp ) ) != IVAS_ERR_OK ) #endif diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index b9804bada1..34be33c7df 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -177,8 +177,21 @@ ivas_error IVAS_DEC_PrepareRenderer( ); #endif +#ifdef OBJ_EDITING_API /*! r: decoder error code */ +ivas_error IVAS_DEC_GetSamplesDecoder( + IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ + const int16_t isSplitRend, /* i : split rendering enabled flag */ + ISAR_SPLIT_REND_BITS_DATA *splitRendBits /* o : output split rendering bits */ +); + +#endif +/*! r: decoder error code */ +#ifdef OBJ_EDITING_API +ivas_error IVAS_DEC_GetSamplesRenderer( +#else ivas_error IVAS_DEC_GetSamples( +#endif IVAS_DEC_HANDLE hIvasDec, /* i/o: IVAS decoder handle */ const int16_t nSamplesAsked, /* i : number of samples wanted by the caller */ const IVAS_DEC_PCM_TYPE pcmType, /* i : type for the decoded PCM resolution */ -- GitLab From 0ab1e48cb73397eaf4efec788b6396f0680597c0 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 18 Sep 2024 12:49:16 +0200 Subject: [PATCH 10/18] FIX_BRATE_SWITCHING: fix bitrate switching cases in OMASA and OSBA --- lib_com/options.h | 1 + lib_dec/ivas_init_dec.c | 4 ++++ lib_dec/lib_dec.c | 16 +++++++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index a4df05ee14..aca5b040b8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -161,6 +161,7 @@ #define OBJ_EDITING_EXAMPLE /* obj editing example code in decoder.c */ #define OMASA_OBJECT_EDITING /* Nokia: object editing interface for OMASA */ #define OBJ_EDITING_PARAMISM_BIN /* Nokia: object editing for ParamISM to binaural */ +#define FIX_BRATE_SWITCHING /* VA: fix bitrate switching cases in OMASA and OSBA */ #endif /* ################### Start BE switches ################################# */ diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index c7e71ab466..204109fc26 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -2911,7 +2911,11 @@ static ivas_error doSanityChecks_IVAS( #ifdef OBJ_EDITING_COMMANDLINE if ( st_ivas->hDecoderConfig->Opt_ObjEdit_on ) { +#ifdef FIX_BRATE_SWITCHING + if ( !( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT || ( st_ivas->ivas_format == MASA_FORMAT && st_ivas->nchan_ism > 0 ) ) ) +#else if ( !( st_ivas->ivas_format == ISM_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) ) +#endif { return IVAS_ERROR( IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED, "Wrong set-up: Obect editing is not supported in this IVAS format." ); } diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 3f18a9aa76..6e5aa32b00 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -956,9 +956,16 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_BRATE_SWITCHING + if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || + hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || + ( hIvasDec->st_ivas->ivas_format == MASA_FORMAT && hIvasDec->st_ivas->nchan_ism > 0 ) ) ) +#else if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) ) +#endif { return IVAS_ERROR( IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED, "Object editing is not supported in this operation mode." ); } @@ -1082,12 +1089,19 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef FIX_BRATE_SWITCHING + if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || + hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT || + hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || + ( hIvasDec->st_ivas->ivas_format == MASA_FORMAT && hIvasDec->st_ivas->nchan_ism > 0 ) ) ) +#else if ( !( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || ( hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT && hIvasDec->st_ivas->ism_mode == ISM_SBA_MODE_DISC ) || ( hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT && ( hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ || hIvasDec->st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) ) || hIvasDec->st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) +#endif { - return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); + return IVAS_ERROR( IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED, "Object editing no supported in this operation mode." ); } if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) -- GitLab From 4d4d44c10ae8d61f64d25e6794387891d85dacf4 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 7 Oct 2024 12:50:44 +0200 Subject: [PATCH 11/18] enable object editing in the JBM path --- lib_dec/lib_dec.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 75b67e1e87..b2d7266160 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -104,7 +104,6 @@ struct IVAS_DEC void *flushbuffer; IVAS_DEC_PCM_TYPE pcmType; bool hasEditableParameters; - bool enableParameterEditing; bool hasBeenPreparedRendering; #endif }; @@ -189,7 +188,6 @@ ivas_error IVAS_DEC_Open( hIvasDec->pcmType = IVAS_DEC_PCM_INVALID; hIvasDec->nSamplesFlushed = 0; hIvasDec->hasEditableParameters = false; - hIvasDec->enableParameterEditing = false; hIvasDec->hasBeenPreparedRendering = false; #endif @@ -3535,7 +3533,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( #ifdef OBJ_EDITING_API /* :TODO: only return here if we really have editing initialized */ // VE: please address - if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) + if ( hIvasDec->hasBeenFedFirstGoodFrame ) { *parametersAvailableForEditing = true; return IVAS_ERR_OK; -- GitLab From 07a7e56337f58513b9ded08943c8ed990c6796a1 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 7 Oct 2024 12:57:39 +0200 Subject: [PATCH 12/18] check for command-line argument before doing object editing in JBM path --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index a4415e0676..d399ba6e1d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3376,7 +3376,7 @@ static ivas_error decodeVoIP( #ifdef OBJ_EDITING_API /* Object metadata editing */ - if ( parameterAvailableForEditing == true ) // VE: harmonize it with decodeG192() + if ( arg.objEditEnabled && parameterAvailableForEditing == true ) // VE: harmonize it with decodeG192() { IVAS_EDITABLE_PARAMETERS editableParameters; -- GitLab From 40e856ef50871f2d02e5ff82e769015876f3bcbe Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 7 Oct 2024 13:13:47 +0200 Subject: [PATCH 13/18] delete the comments regarding parameterAvailableForEditing --- apps/decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/decoder.c b/apps/decoder.c index d399ba6e1d..6d34377d2d 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3376,7 +3376,7 @@ static ivas_error decodeVoIP( #ifdef OBJ_EDITING_API /* Object metadata editing */ - if ( arg.objEditEnabled && parameterAvailableForEditing == true ) // VE: harmonize it with decodeG192() + if ( arg.objEditEnabled && parameterAvailableForEditing == true ) { IVAS_EDITABLE_PARAMETERS editableParameters; -- GitLab From d06676abc8f7753b5810b608d7ba3e8b5c6643d6 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 7 Oct 2024 13:46:51 +0200 Subject: [PATCH 14/18] fix crash when running OSBA pre-rendered modes with -obj_edit --- lib_dec/lib_dec.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index b2d7266160..6f00f1f78d 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1018,6 +1018,10 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } } + else if (hIvasDec->st_ivas->ism_mode == ISM_MODE_NONE ) + { + hIvasEditableParameters->num_obj = 0; + } #ifdef DEBUGGING else { @@ -1181,6 +1185,13 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; #endif } + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_NONE ) + { + if ( hIvasEditableParameters.num_obj != 0 ) + { + return IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED; + } + } else { assert( 0 && "This should never happen!" ); @@ -3532,7 +3543,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #ifdef OBJ_EDITING_API - /* :TODO: only return here if we really have editing initialized */ // VE: please address if ( hIvasDec->hasBeenFedFirstGoodFrame ) { *parametersAvailableForEditing = true; -- GitLab From 833abda3e5e3992ac749a72bfb17f10a960b32a4 Mon Sep 17 00:00:00 2001 From: Dominik Weckbecker Date: Mon, 7 Oct 2024 13:59:13 +0200 Subject: [PATCH 15/18] fix formatting --- lib_dec/lib_dec.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 6f00f1f78d..de61453549 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -1018,10 +1018,10 @@ ivas_error IVAS_DEC_GetEditableParameters( hIvasEditableParameters->ism_metadata[obj].non_diegetic_flag = 0; } } - else if (hIvasDec->st_ivas->ism_mode == ISM_MODE_NONE ) - { - hIvasEditableParameters->num_obj = 0; - } + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_NONE ) + { + hIvasEditableParameters->num_obj = 0; + } #ifdef DEBUGGING else { @@ -1185,13 +1185,13 @@ ivas_error IVAS_DEC_SetEditableParameters( hIvasDec->st_ivas->hMasaIsmData->masa_gain_is_edited = 0u; #endif } - else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_NONE ) - { - if ( hIvasEditableParameters.num_obj != 0 ) - { - return IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED; - } - } + else if ( hIvasDec->st_ivas->ism_mode == ISM_MODE_NONE ) + { + if ( hIvasEditableParameters.num_obj != 0 ) + { + return IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED; + } + } else { assert( 0 && "This should never happen!" ); -- GitLab From bf2a66e1e1264f42db72d8312cfd42c1e8e71b07 Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 16 Oct 2024 12:43:06 +0200 Subject: [PATCH 16/18] comment, formatting --- lib_dec/ivas_ism_param_dec.c | 1 + lib_dec/ivas_mc_param_dec.c | 2 ++ lib_dec/lib_dec.c | 12 ++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_ism_param_dec.c b/lib_dec/ivas_ism_param_dec.c index a0696905d9..db93983e59 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -1134,6 +1134,7 @@ void ivas_param_ism_dec_prepare_renderer( } #endif + /*-------------------------------------------------------------------------* * ivas_ism_param_dec_tc_gain_ajust() * diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 43196cc5da..59d3c1cb79 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1628,6 +1628,7 @@ void ivas_param_mc_dec_prepare_renderer( { continue; } + ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot( &hParamMC->Cldfb_RealBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], &hParamMC->Cldfb_ImagBuffer_tc[slot_idx * hParamMC->num_freq_bands * nchan_transport], is_next_band ? cx_next_band : cx, @@ -1680,6 +1681,7 @@ void ivas_param_mc_dec_prepare_renderer( { continue; } + /* generate mixing matrices */ ivas_param_mc_get_mixing_matrices( hParamMC, hSynthesisOutputSetup, diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index de61453549..e9ac9996b0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -555,7 +555,7 @@ ivas_error IVAS_DEC_Configure( hIvasDec->flushbuffer = (void *) malloc( CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( int16_t ) ); if ( hIvasDec->flushbuffer == NULL ) { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate flush buffer" ); + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate JBM flush buffer" ); } hIvasDec->pcmType = IVAS_DEC_PCM_INT16; set_s( (int16_t *) hIvasDec->flushbuffer, 0, CPE_CHANNELS * hIvasDec->nSamplesFrame / IVAS_MAX_PARAM_SPATIAL_SUBFRAMES ); @@ -1440,7 +1440,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } hIvasDec->hasBeenPreparedRendering = false; - if ( hIvasDec->st_ivas->hIsmMetaData[0] ) + if ( hIvasDec->st_ivas->hIsmMetaData[0] != NULL ) { if ( hIvasDec->st_ivas->ivas_format == ISM_FORMAT || hIvasDec->st_ivas->ivas_format == MASA_ISM_FORMAT || hIvasDec->st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -2875,6 +2875,13 @@ ivas_error IVAS_DEC_GetRenderConfig( return copyRendererConfigStruct( hIvasDec->st_ivas->hRenderConfig, hRCout ); } + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetDefaultRenderConfig( ) + * + * + *---------------------------------------------------------------------*/ + /*! r: error code*/ ivas_error IVAS_DEC_GetDefaultRenderConfig( IVAS_RENDER_CONFIG_HANDLE hRCout /* o : Render config handle */ @@ -3255,6 +3262,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * -- GitLab From bfb475ddb9adb2d77b8c8d593eb85aa33b3be645 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 22 Oct 2024 12:57:14 +0200 Subject: [PATCH 17/18] remove unused parameter 'hIvasDec->hasEditableParameters' --- lib_dec/lib_dec.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib_dec/lib_dec.c b/lib_dec/lib_dec.c index 864a12dc9c..041d871db0 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -103,7 +103,6 @@ struct IVAS_DEC uint16_t nSamplesFlushed; void *flushbuffer; IVAS_DEC_PCM_TYPE pcmType; - bool hasEditableParameters; bool hasBeenPreparedRendering; #endif }; @@ -191,7 +190,6 @@ ivas_error IVAS_DEC_Open( hIvasDec->flushbuffer = NULL; hIvasDec->pcmType = IVAS_DEC_PCM_INVALID; hIvasDec->nSamplesFlushed = 0; - hIvasDec->hasEditableParameters = false; hIvasDec->hasBeenPreparedRendering = false; #endif -- GitLab From dbd778d239e13a32ca81da4efbfd692e733f0c0e Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 31 Oct 2024 11:59:54 +0100 Subject: [PATCH 18/18] remove unused declaration ivas_ism_renderer_update_md() --- lib_com/ivas_prot.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 111ccbaddd..847cb924f4 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -1036,11 +1036,6 @@ ivas_error ivas_ism_metadata_dec( DEC_CORE_HANDLE st0 /* i : core-coder handle */ ); -#ifdef OBJ_EDITING_API -void ivas_ism_renderer_update_md( - Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ -); -#endif /*----------------------------------------------------------------------------------* * Parametric ISM prototypes -- GitLab