diff --git a/apps/decoder.c b/apps/decoder.c index 01d4cf3356171c2876cf01b773c452d61e1707f3..c2c64e6ade11b3a284ff2198d2184b831001c152 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 @@ -155,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 @@ -202,6 +197,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 void do_object_editing( IVAS_EDITABLE_PARAMETERS *editableParameters ); +#endif + /*------------------------------------------------------------------------------------------* * main() @@ -452,8 +451,13 @@ int main( asked_frame_size = arg.renderFramesize; uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; +#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 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; @@ -1155,11 +1159,10 @@ static bool parseCmdlIVAS_dec( arg->directivityPatternId[i] = 65535; } -#ifdef OBJ_EDITING_EXAMPLE +#ifdef OBJ_EDITING_COMMANDLINE arg->objEditEnabled = false; -#endif - +#endif /*-----------------------------------------------------------------* * Initialization *-----------------------------------------------------------------*/ @@ -1612,8 +1615,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; @@ -1821,13 +1823,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 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" ); 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" ); @@ -2198,10 +2200,6 @@ static ivas_error decodeG192( return error; } -#ifdef OBJ_EDITING_API - IVAS_EDITABLE_PARAMETERS editableParameters; -#endif - IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; @@ -2502,16 +2500,19 @@ static ivas_error decodeG192( } } #endif +#ifdef FIX_HRTF_LOAD + /* Feed into decoder and decode transport channels */ + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi ) ) != IVAS_ERR_OK ) +#else /* Feed into decoder */ if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, bit_stream, num_bits, bfi -#ifndef FIX_HRTF_LOAD #ifdef OBJ_EDITING_API , isSplitRend, splitRendBits -#endif #endif ) ) != IVAS_ERR_OK ) +#endif { fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) ); goto cleanup; @@ -2547,74 +2548,41 @@ static ivas_error decodeG192( #endif #ifdef OBJ_EDITING_API -#ifdef OBJ_EDITING_EXAMPLE + /* Object metadata 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 ) { 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; + return error; } - editableParameters.gain_bed = 0.5f; + /* Do object metadata editing here ... */ +#ifdef OBJ_EDITING_EXAMPLE + do_object_editing( &editableParameters ); - /* set new object parameters*/ +#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 ) ); - goto cleanup; + return error; } } -#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 + /* Render */ if ( isSplitRend ) { if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) @@ -2628,14 +2596,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++; @@ -3459,29 +3437,34 @@ 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 FIX_HRTF_LOAD - , - &bitstreamReadDone +#ifdef OBJ_EDITING_API + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, systemTime_ms ) ) != IVAS_ERR_OK ) #endif +#else #ifdef OBJ_EDITING_API - , - &nSamplesRendered, ¶meterAvailableForEditing + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &nSamplesRendered, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif #endif - ) ) != IVAS_ERR_OK ) #else - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing #ifdef FIX_HRTF_LOAD - , - &bitstreamReadDone +#ifdef OBJ_EDITING_API + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, &nSamplesRendered, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, systemTime_ms ) ) != IVAS_ERR_OK ) #endif +#else #ifdef OBJ_EDITING_API - & nSamplesRendered, - ¶meterAvailableForEditing + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &nSamplesRendered, ¶meterAvailableForEditing ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK ) +#endif #endif - ) ) != IVAS_ERR_OK ) #endif { fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) ); @@ -3515,9 +3498,29 @@ static ivas_error decodeVoIP( #endif #ifdef OBJ_EDITING_API - if ( parameterAvailableForEditing == true ) + /* Object metadata editing */ + if ( arg.objEditEnabled && parameterAvailableForEditing == true ) { - /* do the object editing here */ + 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 ) ); + 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 @@ -3803,6 +3806,60 @@ cleanup: return error; } +#ifdef OBJ_EDITING_EXAMPLE + +/*---------------------------------------------------------------------* + * do_object_editing() + * + * Example function to edit objects parameters + *---------------------------------------------------------------------*/ + +static void do_object_editing( + IVAS_EDITABLE_PARAMETERS *editableParameters ) +{ + /* 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; + + + return; +} + +#endif #ifdef DEBUGGING diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index 53b03e4e1f62034739b70a9949eed896e00e8dc5..c0123bf7fdd918b52b30b1677a00bb592adf085e 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_error.h b/lib_com/ivas_error.h index 11727c4e5deee06032b2d7ff1b63db8e396058d3..905be753a5a2ef08ae4903c377d0d76666ece15d 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_com/ivas_prot.h b/lib_com/ivas_prot.h index c8d1a8169a17a7293d5a425a0a87e9059c02ef68..847cb924f46d5b45aefd38e1009b9e23d6c83248 100755 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -822,7 +822,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( ); #ifdef OBJ_EDITING_API -void ivas_jbm_dec_prepare_renderer( +void ivas_dec_prepare_renderer( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif @@ -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: main IVAS decoder handle */ -); -#endif /*----------------------------------------------------------------------------------* * Parametric ISM prototypes @@ -1114,18 +1109,18 @@ void ivas_ism_dec_digest_tc( void ivas_param_ism_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const uint16_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ ); #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 CLDFB slots in transport channels */ ); #endif @@ -3811,7 +3806,7 @@ void ivas_mc_paramupmix_dec_read_BS( void ivas_mc_paramupmix_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ const int16_t nSamplesForRendering /* i : number of samples provided */ ); @@ -3881,14 +3876,14 @@ void ivas_param_mc_dec_read_BS( void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output*/ + const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output*/ ); #ifdef OBJ_EDITING_API void ivas_param_mc_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLDFB slots in the transport channels */ ); #endif @@ -5630,6 +5625,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 */ ); @@ -5638,6 +5645,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_com/options.h b/lib_com/options.h index 02242424154b9a8c65e3b9ce734d67e873276ff1..cca1834d0acf422845232941cd4bf3397f594538 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -157,9 +157,11 @@ #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 */ +#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 fa737acfaa388efe3780fb04f083e8ef7d7eeda8..006f23216a7731f1839d2202946704a839e12750 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -3331,6 +3331,19 @@ 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." ); + } + } +#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_ism_dec.c b/lib_dec/ivas_ism_dec.c index 67f189e29958f2742eada992dde248f3ccb8dcfb..69ee95e0ac984ead3dbeae2afe5736261a427212 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -190,9 +190,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 ace799d92e720c2a8967c8293a24420ddea6b1d4..db93983e592bbd9a547ffd5027e8711e651d433d 100644 --- a/lib_dec/ivas_ism_param_dec.c +++ b/lib_dec/ivas_ism_param_dec.c @@ -802,9 +802,9 @@ void ivas_ism_dec_digest_tc( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint16_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint16_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { #ifndef OBJ_EDITING_API @@ -850,8 +850,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 @@ -929,8 +929,8 @@ void ivas_param_ism_dec_digest_tc( } } } -#endif +#endif if ( st_ivas->hDecoderConfig->Opt_tsm ) { /*TODO : FhG to check*/ @@ -944,7 +944,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]; @@ -952,8 +951,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 } @@ -978,13 +977,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 ) ) @@ -1009,8 +1009,8 @@ void ivas_param_ism_dec_dequant_md( *-------------------------------------------------------------------------*/ 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 CLDFB slots in transport channels */ ) { int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; @@ -1134,6 +1134,7 @@ void ivas_param_ism_dec_prepare_renderer( } #endif + /*-------------------------------------------------------------------------* * ivas_ism_param_dec_tc_gain_ajust() * @@ -1450,8 +1451,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; @@ -1524,6 +1525,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 9b882089b15dfef4ccfe335236defb1b4ce842ce..4e4fb628a44cb3d8bec825760f569ef9bada1f93 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 4cb5aac155ba8cd41a4e54518e2b2cbdabec47fa..f096ff4116fc6f79f7644ddfad82c3e2963767b4 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,20 +2980,21 @@ void ivas_jbm_masa_sf_to_sf_map( return; } + #ifdef OBJ_EDITING_API /*--------------------------------------------------------------------------* - * ivas_jbm_dec_prepare_renderer() + * ivas_dec_prepare_renderer() * - * prepare IVAS JBM renderer routine + * prepare IVAS renderer routine *--------------------------------------------------------------------------*/ -void ivas_jbm_dec_prepare_renderer( +void ivas_dec_prepare_renderer( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { int16_t n, n_render_timeslots; - push_wmops( "ivas_jbm_dec_prepare_renderer" ); + push_wmops( "ivas_dec_prepare_renderer" ); n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; @@ -3031,7 +3013,6 @@ void ivas_jbm_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 ) @@ -3055,7 +3036,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 ); @@ -3118,18 +3098,20 @@ void ivas_jbm_dec_prepare_renderer( if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC ) { - int16_t num_objects; + int16_t nchan_transport_ism; + /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ - num_objects = 0; + nchan_transport_ism = 0; if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC ) { - num_objects = 1; + nchan_transport_ism = 1; } else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { - num_objects = st_ivas->nchan_ism; + nchan_transport_ism = st_ivas->nchan_ism; } - for ( n = 0; n < num_objects; n++ ) + + for ( n = 0; n < nchan_transport_ism; n++ ) { if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC ) { @@ -3147,12 +3129,14 @@ void ivas_jbm_dec_prepare_renderer( v_multc( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN, st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); #endif } + if ( st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && st_ivas->hDecoderConfig->output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) { delay_signal( st_ivas->hTcBuffer->tc[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size ); } } #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 +3144,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 934fc6fac24e34dd8e54f9ef6cbf3fb46ec3b090..59d3c1cb79b5a831fc738763b5a159351b5cb106 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -1322,8 +1322,8 @@ void ivas_param_mc_dec_read_BS( void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - float *transport_channels_f[] /* i : synthesized core-coder transport channels/DirAC output */ + const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + float *transport_channels_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ ) { PARAM_MC_DEC_HANDLE hParamMC; @@ -1349,8 +1349,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 ); @@ -1524,6 +1524,7 @@ void ivas_param_mc_dec_digest_tc( return; } + #ifdef OBJ_EDITING_API /*------------------------------------------------------------------------- * ivas_param_mc_dec_prepare_renderer() @@ -1532,8 +1533,8 @@ void ivas_param_mc_dec_digest_tc( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots /* i : number of CLDFB slots in transport channels */ ) { PARAM_MC_DEC_HANDLE hParamMC; @@ -1605,7 +1606,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 ); - /* loop over two bands at a time */ for ( param_band_idx = 0; param_band_idx < hParamMC->num_param_bands_synth; param_band_idx += 2 ) { @@ -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/ivas_mc_paramupmix_dec.c b/lib_dec/ivas_mc_paramupmix_dec.c index 41cdf081fb4c0d16622744e798c2487706490fd4..0748d26bec2333db61809a400bcf24783b8cc656 100644 --- a/lib_dec/ivas_mc_paramupmix_dec.c +++ b/lib_dec/ivas_mc_paramupmix_dec.c @@ -186,9 +186,9 @@ void ivas_mc_paramupmix_dec_read_BS( *------------------------------------------------------------------------*/ void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const uint8_t nCldfbSlots, /* i : number of CLFBS slots in the transport channels*/ - const int16_t nSamplesForRendering /* i : number of samples provided */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const uint8_t nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + const int16_t nSamplesForRendering /* i : number of samples provided */ ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; diff --git a/lib_dec/ivas_objectRenderer_internal.c b/lib_dec/ivas_objectRenderer_internal.c index 1ecfe86db1b47fbecc0a997975ab7931a3b332b7..0e6c1025df49ff6250f3a47918635d3f79e1343f 100644 --- a/lib_dec/ivas_objectRenderer_internal.c +++ b/lib_dec/ivas_objectRenderer_internal.c @@ -180,6 +180,7 @@ ivas_error ivas_td_binaural_renderer_sf( c_indx++; } } + if ( subframe_idx == ism_md_subframe_update_jbm ) { #ifdef OBJ_EDITING_API @@ -187,6 +188,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 243b5cf44a6dbd9a51adb0967fb979a2ea8fb144..439a6baba10ca197fb6fc732460f61eb9944ff3b 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -800,6 +800,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] ) @@ -808,6 +809,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 eaf5d11a7e894e41a6aab1229e5329a593567797..bb5f547beb299fd4f8d08244e4879593313a8124 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/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 2515b1cc99cd3610a05685511cb51fd1e86fe1cf..9ed05b1ae203c99fd806c028a6bd05b12d25bf6a 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1028,6 +1028,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_COMMANDLINE + 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 c28ceb430d31e9405224a2dd9e99ec34f7cd5983..3b42e56a128515488703f0effbe7ac7e2ecde6e6 100644 --- a/lib_dec/lib_dec.c +++ b/lib_dec/lib_dec.c @@ -103,8 +103,6 @@ struct IVAS_DEC uint16_t nSamplesFlushed; void *flushbuffer; IVAS_DEC_PCM_TYPE pcmType; - bool hasEditableParameters; - bool enableParameterEditing; bool hasBeenPreparedRendering; #endif }; @@ -192,8 +190,6 @@ ivas_error IVAS_DEC_Open( hIvasDec->flushbuffer = NULL; hIvasDec->pcmType = IVAS_DEC_PCM_INVALID; hIvasDec->nSamplesFlushed = 0; - hIvasDec->hasEditableParameters = false; - hIvasDec->enableParameterEditing = false; hIvasDec->hasBeenPreparedRendering = false; #endif @@ -327,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_COMMANDLINE + hDecoderConfig->Opt_ObjEdit_on = 0; +#endif return; } @@ -369,12 +368,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; @@ -441,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_COMMANDLINE + const bool objEditEnabled, /* i : enable object editing */ +#endif + const bool delayCompensationEnabled /* i : enable delay compensation */ ) { Decoder_Struct *st_ivas; @@ -499,6 +503,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_COMMANDLINE + hDecoderConfig->Opt_ObjEdit_on = (int16_t) objEditEnabled; +#endif if ( renderFramesize == IVAS_RENDER_FRAMESIZE_UNKNOWN ) { @@ -545,6 +552,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 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 ); } @@ -827,12 +838,15 @@ 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 */ -#ifndef FIX_HRTF_LOAD +#ifdef FIX_HRTF_LOAD + int16_t bfi /* i : bad frame indicator flag */ +#else #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 #endif ) @@ -911,128 +925,14 @@ ivas_error IVAS_DEC_FeedFrame_Serial( hIvasDec->nSamplesRendered = 0; hIvasDec->nSamplesAvailableNext = hIvasDec->nSamplesFrame; -#ifdef OBJ_EDITING_API #ifndef FIX_HRTF_LOAD - /* 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 ) - { - 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] ) +#ifdef OBJ_EDITING_API + /* Decode TCs, do TSM and feed to renderer */; + if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK ) { - 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 #endif return IVAS_ERR_OK; @@ -1173,6 +1073,8 @@ ivas_error IVAS_DEC_ReadFormat( return IVAS_ERR_OK; } +#endif +#if ( defined FIX_HRTF_LOAD || defined OBJ_EDITING_API ) /*---------------------------------------------------------------------* * IVAS_DEC_GetSamplesDecoder( ) @@ -1278,6 +1180,8 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } hIvasDec->hasBeenFedFrame = false; } + +#ifdef OBJ_EDITING_API hIvasDec->hasBeenPreparedRendering = false; if ( hIvasDec->st_ivas->hIsmMetaData[0] ) @@ -1323,6 +1227,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( } } } +#endif return IVAS_ERR_OK; } @@ -1335,18 +1240,31 @@ ivas_error IVAS_DEC_GetSamplesDecoder( * * *---------------------------------------------------------------------*/ + 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; + } + +#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_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 ) @@ -1360,7 +1278,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; @@ -1371,6 +1288,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; @@ -1378,7 +1296,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]; @@ -1390,17 +1307,21 @@ 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 { 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++ ) @@ -1447,29 +1368,41 @@ 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; + } +#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 ) @@ -1477,8 +1410,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 @@ -1487,7 +1418,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; @@ -1509,7 +1439,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 @@ -1539,11 +1468,19 @@ 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; #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!" ); @@ -1552,8 +1489,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++ ) @@ -1598,7 +1534,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]; @@ -1670,34 +1606,43 @@ ivas_error IVAS_DEC_SetEditableParameters( } #endif - return error; + return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_PrepareRenderer( ) * - * prepare IVAS JBM renderer + * prepare IVAS renderer *---------------------------------------------------------------------*/ + ivas_error IVAS_DEC_PrepareRenderer( IVAS_DEC_HANDLE hIvasDec ) { - ivas_error error; - - error = IVAS_ERR_OK; - - if ( hIvasDec == NULL ) + if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); + ivas_dec_prepare_renderer( hIvasDec->st_ivas ); + hIvasDec->hasBeenPreparedRendering = true; - return error; -} + return IVAS_ERR_OK; +} #endif +#ifdef OBJ_EDITING_API + +/*---------------------------------------------------------------------* + * IVAS_DEC_GetSamplesRenderer( ) + * + * Main function to render the decoded data to output data + *---------------------------------------------------------------------*/ + +ivas_error IVAS_DEC_GetSamplesRenderer( +#else /*---------------------------------------------------------------------* * IVAS_DEC_GetSamples( ) * @@ -1706,6 +1651,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 */ @@ -1733,7 +1679,6 @@ ivas_error IVAS_DEC_GetSamples( nTransportChannels = 0; #endif - if ( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -1807,9 +1752,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; @@ -1872,34 +1817,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; @@ -1919,7 +1864,9 @@ ivas_error IVAS_DEC_GetSamples( { *needNewFrame = false; } +#ifndef OBJ_EDITING_API } +#endif } *nOutSamples = nSamplesRendered; @@ -1981,8 +1928,8 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { return error; } -#endif +#endif numPoses = hSplitBinRend->splitrend.multiBinPoseData.num_poses; #ifdef OBJ_EDITING_API @@ -1990,6 +1937,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 ); } @@ -2025,11 +1976,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 ) @@ -2609,7 +2568,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]; @@ -2621,7 +2579,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; @@ -3203,6 +3160,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 */ @@ -3605,6 +3569,7 @@ ivas_error IVAS_DEC_VoIP_FeedFrame( return IVAS_ERR_OK; } + /*---------------------------------------------------------------------* * IVAS_DEC_VoIP_SetScale( ) * @@ -3681,25 +3646,22 @@ 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 */ - const uint32_t systemTimestamp_ms /* i : current system timestamp */ + 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 SUPPORT_JBM_TRACEFILE - , JbmTraceFileWriterFn jbmWriterFn, - void *jbmWriter + void *jbmWriter, #endif #ifdef FIX_HRTF_LOAD - , - bool *bitstreamReadDone + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ #endif #ifdef OBJ_EDITING_API - , - uint16_t *nSamplesRendered, - bool *parametersAvailableForEditing + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ #endif + const uint32_t systemTimestamp_ms /* i : current system timestamp */ ) { Decoder_Struct *st_ivas; @@ -3814,16 +3776,15 @@ 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 -#ifndef FIX_HRTF_LOAD -#if defined( OBJ_EDITING_API ) - , - 0, - 0 +#ifdef FIX_HRTF_LOAD + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, dataUnit->dataSize, 0 ) ) != IVAS_ERR_OK ) +#else +#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 #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -3835,15 +3796,15 @@ 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 -#ifndef FIX_HRTF_LOAD -#if defined( OBJ_EDITING_API ) - , - 0, - 0 +#ifdef FIX_HRTF_LOAD + if ( ( error = IVAS_DEC_FeedFrame_Serial( hIvasDec, hIvasDec->hVoIP->bs_conversion_buf, 0, 1 ) ) != IVAS_ERR_OK ) +#else +#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 #endif - ) ) != IVAS_ERR_OK ) { return error; } @@ -3890,9 +3851,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 */ - if ( hIvasDec->hasBeenFedFirstGoodFrame && hIvasDec->hasEditableParameters == true && hIvasDec->enableParameterEditing == true ) + if ( hIvasDec->hasBeenFedFirstGoodFrame ) { *parametersAvailableForEditing = true; return IVAS_ERR_OK; @@ -3924,6 +3885,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( bool tmp; #ifdef FIX_HRTF_LOAD + /* decode TCs, do TSM and prepare the renderer */ if ( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { if ( hIvasDec->nSamplesAvailableNext == 0 || hIvasDec->nSamplesAvailableNext == hIvasDec->nSamplesFrame ) @@ -3952,7 +3914,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; @@ -3960,9 +3921,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 @@ -4461,6 +4422,13 @@ static ivas_error printConfigInfo_dec( { fprintf( stdout, "Acoustic environment ID:ON\n" ); } +#ifdef OBJ_EDITING_COMMANDLINE + + 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 64f6b883d42d4aafbdb740078e7d1f9c4b00cb05..fb5cee39fa042d36f9fd61bc22c9e37a624eac44 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_COMMANDLINE + const bool objEditEnabled, /* i : enable object editing */ +#endif const bool delayCompensationEnabled /* i : enable delay compensation */ ); @@ -149,12 +152,15 @@ 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 FIX_HRTF_LOAD + int16_t bfi /* i : bad frame indicator flag */ +#else +#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 */ -#ifndef FIX_HRTF_LOAD -#if defined( OBJ_EDITING_API ) - , - int16_t isSplitRend, - ISAR_SPLIT_REND_BITS_DATA *splitRendBits #endif #endif ); @@ -168,6 +174,9 @@ ivas_error IVAS_DEC_ReadFormat( IVAS_AUDIO_CONFIG *intern_audio_config /* o : internal audio configuration */ ); +#endif +#if( defined FIX_HRTF_LOAD || defined 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 */ @@ -177,13 +186,13 @@ ivas_error IVAS_DEC_GetSamplesDecoder( #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( @@ -192,7 +201,11 @@ ivas_error IVAS_DEC_PrepareRenderer( #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 */ @@ -317,20 +330,18 @@ 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 SUPPORT_JBM_TRACEFILE - , JbmTraceFileWriterFn jbmWriterFn, - void* jbmWriter + JbmTraceFileWriterFn jbmWriterFn, + void *jbmWriter, #endif #ifdef FIX_HRTF_LOAD - , - bool *bitstreamReadDone + bool *bitstreamReadDone, /* o : flag indicating that bitstream was read */ #endif #ifdef OBJ_EDITING_API - , - uint16_t *nSamplesRendered, - bool *parametersAvailableForEditing + uint16_t *nSamplesRendered, /* o : number of samples rendered */ + bool *parametersAvailableForEditing, /* o : indicates whether objects editing is available */ #endif + const uint32_t systemTimestamp_ms /* i : current system timestamp */ ); ivas_error IVAS_DEC_Flush( diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index 448c50c6952ed5fcb255d9ce4ca0237383d52bde..19b08dbe81e4498520231e8e52bee2fe074e7417 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -1246,6 +1246,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] ) { @@ -3015,7 +3016,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects( float masaEneThisCh[2]; float ratioAccNewDivisor; - gainMasaPow2 = 1.0f; if ( masaGainEdited ) { @@ -3049,6 +3049,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 dbe5cc8d0675ff9b442b11d7bfd4bd1e558fe8e6..4b1c5764b7aeacb062136a52403c5603610a018d 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 4f570e6182897732a508e0767ec18c75affb86d8..6079f93b5bcf703e9ada4f28c78509a14956dbee 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 32f7246ef5c79c4ce398ddf738a11ff22ef5d1ad..b3a826e71ee7b99963b23ab35b261596b78af1f1 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 diff --git a/readme.txt b/readme.txt index e6fbd729ead207359e6e304a12d7ea5f9ff29388..fb183d6f9e08dd5351d35321ab22907ca58e4c47 100644 --- a/readme.txt +++ b/readme.txt @@ -260,8 +260,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. @@ -289,7 +289,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' @@ -305,8 +305,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). @@ -327,7 +328,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) @@ -340,8 +341,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)