From 993008df4c082255eafcf1e31ea86a4b1ef6eb51 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 10:07:40 +0200 Subject: [PATCH 1/9] port MRs --- apps/decoder.c | 137 ++++++++++++++++++---- lib_com/common_api_types.h | 5 +- lib_com/ivas_error.h | 7 ++ lib_com/ivas_prot_fx.h | 42 ++++--- lib_com/options.h | 8 +- lib_dec/ivas_init_dec_fx.c | 21 ++++ lib_dec/ivas_ism_param_dec_fx.c | 27 +++-- lib_dec/ivas_jbm_dec_fx.c | 38 +++--- lib_dec/ivas_mc_param_dec_fx.c | 26 ++-- lib_dec/ivas_mc_paramupmix_dec_fx.c | 8 +- lib_dec/ivas_osba_dec_fx.c | 64 ++++++++++ lib_dec/ivas_stat_dec.h | 5 +- lib_dec/lib_dec.h | 13 +- lib_dec/lib_dec_fx.c | 136 ++++++++++++++------- lib_rend/ivas_objectRenderer_sources_fx.c | 6 +- readme.txt | 5 +- 16 files changed, 407 insertions(+), 141 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 824b3487d..8cca8af76 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -51,11 +51,6 @@ #include "wmc_auto.h" #include "options.h" #include "stl.h" -#ifdef OBJ_EDITING_API -#ifdef OBJ_EDITING_EXAMPLE -#include -#endif -#endif #define WMC_TOOL_SKIP @@ -140,7 +135,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 @@ -174,6 +169,9 @@ static void usage_dec( void ); static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf ); static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec ); static ivas_error load_hrtf_from_file( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const IVAS_AUDIO_CONFIG OutputConfig, const int32_t output_Fs ); +#ifdef OBJ_EDITING_EXAMPLE +static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters ); +#endif /*------------------------------------------------------------------------------------------* @@ -407,7 +405,15 @@ int main( uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535; #ifdef LIB_DEC_REVISION - if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, 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_fx, arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#ifdef OBJ_EDITING_COMMANDLINE + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, 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_fx, arg.dpidEnabled, aeID, arg.objEditEnabled, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#else + if ( ( error = IVAS_DEC_Configure( hIvasDec, arg.output_Fs, arg.outputConfig, 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_fx, arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) +#endif #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_fx, arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK ) @@ -873,7 +879,7 @@ static bool parseCmdlIVAS_dec( { arg->directivityPatternId[i] = 65535; } -#ifdef OBJ_EDITING_EXAMPLE +#ifdef OBJ_EDITING_COMMANDLINE arg->objEditEnabled = false; #endif @@ -1344,7 +1350,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; @@ -1539,6 +1545,10 @@ static void usage_dec( void ) fprintf( stdout, " without braces and spaces, with ':' character separating ID from duration and ',' separating\n" ); fprintf( stdout, " ID and duration pairs, where duration is specified in frames\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" ); @@ -1904,11 +1914,6 @@ static ivas_error decodeG192( int16_t isSplitRend, isSplitCoded; IVAS_RENDER_CONFIG_DATA renderConfig; RenderConfigReader *renderConfigReader = NULL; -#ifdef OBJ_EDITING_API -#ifdef OBJ_EDITING_EXAMPLE - IVAS_EDITABLE_PARAMETERS editableParameters; -#endif -#endif #ifdef VARIABLE_SPEED_DECODING #ifdef LIB_DEC_REVISION @@ -2196,18 +2201,21 @@ static ivas_error decodeG192( } #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; + return error; } +#ifdef OBJ_EDITING_EXAMPLE + /* Do object metadata editing here ... */ + do_object_editing_fx( &editableParameters ); +#else /* edit object parameters...*/ /* put the objects equally spaced at the horizontal plane */ @@ -2246,6 +2254,7 @@ static ivas_error decodeG192( } editableParameters.gain_bed_fx = ( 1 << 28 ); // 0.5 in Q29 +#endif /* set new object parameters*/ if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK ) @@ -2254,7 +2263,7 @@ static ivas_error decodeG192( goto cleanup; } } -#endif + /* Do the final preparations needed for rendering */ if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK ) { @@ -2283,7 +2292,7 @@ static ivas_error decodeG192( if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK ) #endif { - 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; } nSamplesRendered += nSamplesRendered_loop; @@ -2298,7 +2307,6 @@ static ivas_error decodeG192( fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame ); } } - } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK ); @@ -2715,7 +2723,7 @@ static ivas_error decodeVoIP( int16_t nOutSamples = 0; bool bitstreamReadDone = false; #ifdef OBJ_EDITING_API - bool parametersAvailableForEditing = false; + bool parameterAvailableForEditing = false; #endif uint16_t nSamplesRendered; @@ -3003,13 +3011,13 @@ static ivas_error decodeVoIP( { #ifdef SUPPORT_JBM_TRACEFILE #ifdef OBJ_EDITING_API - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, systemTime_ms ) ) != IVAS_ERR_OK ) #endif #else #ifdef OBJ_EDITING_API - if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, ¶metersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) + if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, ¶meterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK ) #else if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, systemTime_ms ) ) != IVAS_ERR_OK ) #endif @@ -3044,9 +3052,29 @@ static ivas_error decodeVoIP( } #ifdef OBJ_EDITING_API - if ( parametersAvailableForEditing == 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_fx( &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; + } } #endif } /* while ( nSamplesRendered < nOutSamples ) */ @@ -3338,6 +3366,63 @@ cleanup: return error; } +#ifdef OBJ_EDITING_EXAMPLE + +/*---------------------------------------------------------------------* + * do_object_editing() + * + * Example function to edit objects parameters + *---------------------------------------------------------------------*/ + +static void do_object_editing_fx( + IVAS_EDITABLE_PARAMETERS *editableParameters ) +{ + /* put the objects equally spaced at the horizontal plane */ + /* and play a little bit with the gains... */ + Word16 obj_idx, non_diegetic_obj_idx; + Word16 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_fx = 0; + // TODO: verify Q-format + // editableParameters.ism_metadata[obj_idx].azimuth_fx = (Word32) ( ( start_angle + (float) non_diegetic_obj_idx * angle_inc ) * powf( 2.0f, 22.0f ) ); + editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) ( start_angle + (Word32) non_diegetic_obj_idx * angle_inc * 4194304 /* Q22 */ ); + non_diegetic_obj_idx++; + } + } + } + + /* breakover object gains */ + for ( obj_idx = 0; obj_idx < editableParameters->num_obj; obj_idx++ ) + { + // TODO: verify Q-format + // editableParameters.ism_metadata[obj_idx].gain_fx = (Word32) ( ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f ) * powf( 2.0f, 29.0f ) ); + editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f * 536870912 /*Q29*/ ); + } + + editableParameters->gain_bed_fx = ( 1 << 28 ); // 0.5 in Q29 + + return; +} + +#endif /*---------------------------------------------------------------------* * load_hrtf_from_file() diff --git a/lib_com/common_api_types.h b/lib_com/common_api_types.h index bb0f92445..51d6da287 100644 --- a/lib_com/common_api_types.h +++ b/lib_com/common_api_types.h @@ -138,7 +138,7 @@ typedef struct _IVAS_ISM_METADATA float pitch; Word16 non_diegetic_flag; #ifdef OBJ_EDITING_API - Word32 gain_fx; // Q29 + Word32 gain_fx; /* Q29 */ #endif } IVAS_ISM_METADATA; @@ -148,7 +148,8 @@ typedef struct _IVAS_EDITABLE_PARAMETERS { Word16 num_obj; IVAS_ISM_METADATA ism_metadata[IVAS_MAX_NUM_OBJECTS]; - Word32 gain_bed_fx; // Q29 + Word32 gain_bed_fx; /* Q29 */ + } IVAS_EDITABLE_PARAMETERS; #endif diff --git a/lib_com/ivas_error.h b/lib_com/ivas_error.h index 95731403b..76ad34aa4 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_INVALID_HRTF_SAMPLING_RATE, IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA, @@ -249,6 +252,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_INVALID_HRTF_SAMPLING_RATE: diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 5775170bb..a6c21e1d6 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -783,12 +783,6 @@ ivas_error ivas_ism_metadata_dec_fx( 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 - void ivas_get_ism_sid_quan_bitbudget_fx( const Word16 nchan_ism, /* i : number of objects */ Word16 *nBits_azimuth, /* o : number of Q bits for azimuth */ @@ -3930,6 +3924,17 @@ ivas_error ivas_osba_render_sf_fx( Word32 *p_output[] /* o : rendered time signal */ ); +#ifdef OBJ_EDITING_API +void ivas_osba_stereo_add_channels_fx( + Word32 *tc_fx[], /* i : transport channels */ + Word32 *output_fx[], /* i/o: output channels */ + const Word16 gain_bed_fx, /* i : gain bed value Q11 */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 nchan_ism, /* i : number of ISM channels */ + const Word16 ism_mode, /* i : ISM mode */ + const UWord16 n_samples_to_render /* i : output frame length per channel */ +); +#else void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ @@ -3938,6 +3943,7 @@ void ivas_osba_stereo_add_channels_fx( const Word16 nchan_ism, /* i : number of ISM channels */ const UWord16 n_samples_to_render /* i : output frame length per channel */ ); +#endif void ivas_osba_data_close_fx( SBA_ISM_DATA_HANDLE *hSbaIsmData /* i/o: OSBA rendering handle */ @@ -4254,7 +4260,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( ); #ifdef OBJ_EDITING_API -void ivas_jbm_dec_prepare_renderer( +void ivas_dec_prepare_renderer_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #endif @@ -4326,8 +4332,8 @@ ivas_error ivas_ism_metadata_enc_fx( ); ivas_error ivas_ism_dec_config( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const ISM_MODE last_ism_mode /* i/o: last ISM mode */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const ISM_MODE last_ism_mode /* i/o: last ISM mode */ ); ivas_error ivas_param_ism_dec_open_fx( @@ -4345,21 +4351,21 @@ void ivas_ism_dec_digest_tc_fx( ); void ivas_param_ism_dec_digest_tc_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output */ - Word16 q_tc_in + const Word16 q_tc_in ); #ifdef OBJ_EDITING_API void ivas_param_ism_dec_dequant_md_fx( - Decoder_Struct *st_ivas + Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); void ivas_param_ism_dec_prepare_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const Word16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const Word16 nCldfbSlots /* i : number of CLDFB slots in transport channels */ ); #endif @@ -5157,8 +5163,8 @@ void ivas_param_mc_dec_close_fx( void ivas_param_mc_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - Word32 *transport_channels_f_fx[], - Word16 transport_f_e + Word32 *transport_channels_f_fx[], /* i : synthesized core-coder transport channels/DirAC output */ + const Word16 transport_f_e ); #ifdef OBJ_EDITING_API @@ -6618,7 +6624,7 @@ void ivas_mc_paramupmix_dec_read_BS( Word16 *nb_bits /* o : number of bits written */ ); -void ivas_mc_paramupmix_dec_digest_tc( +void ivas_mc_paramupmix_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ const Word16 nSamplesForRendering /* i : number of samples provided */ diff --git a/lib_com/options.h b/lib_com/options.h index 97ac05c29..5872c5a3d 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,13 +129,17 @@ #ifdef OBJ_EDITING_API #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) #define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE + +#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 OMASA_OBJECT_EDITING /* Nokia: object editing interface for OMASA */ #ifdef OMASA_OBJECT_EDITING #define NONBE_1399_1400_FIX_OBJ_EDIT_ISSUES // Nokia: Fix 1399_1400 issue in float, this is essential for the BASOP porting #endif -#define OBJ_EDITING_PARAMISM_BIN /* Nokia: object editing for ParamISM to binaural */ +#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 */ #define OBJ_EDIT_BASOP +#define NONBE_1217_INIT_OBJ_EDIT /* VA: issue 1217: do object editing only when objects metadata is available */ #endif diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 4a21cada1..3c921766a 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3829,6 +3829,8 @@ static ivas_error doSanityChecks_IVAS( } } + test(); + test(); IF( ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) && NE_32( output_Fs, 48000 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_SAMPLING_RATE, "Error: Only 48kHz output sampling rate is supported for split rendering." ); @@ -3871,5 +3873,24 @@ static ivas_error doSanityChecks_IVAS( } } + +#ifdef OBJ_EDITING_COMMANDLINE + IF( st_ivas->hDecoderConfig->Opt_ObjEdit_on ) + { +#ifdef FIX_BRATE_SWITCHING + test(); + test(); + test(); + test(); + IF( !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) || ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && GT_16( 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 + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 7e25eeb09..1a1a376e8 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1087,16 +1087,18 @@ void ivas_ism_dec_digest_tc_fx( return; } + /*-------------------------------------------------------------------------* * ivas_param_ism_dec_digest_tc() * * *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_digest_tc_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output q_tc_in*/ - Word16 q_tc_in ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output q_tc_in */ + const Word16 q_tc_in ) { move16(); move16(); @@ -1257,6 +1259,7 @@ void ivas_param_ism_dec_digest_tc_fx( { /*TODO : FhG to check*/ ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, fade_len, transport_channels, &q_tc ); + IF( NE_16( q_tc, q_tc_in ) ) { FOR( i = 0; i < 2; i++ ) @@ -1335,12 +1338,10 @@ void ivas_param_ism_dec_digest_tc_fx( return; } - #ifdef OBJ_EDITING_API - /*-------------------------------------------------------------------------* - * ivas_param_ism_dec_prepare_renderer_fx() + * ivas_param_ism_dec_dequant_md() * * *-------------------------------------------------------------------------*/ @@ -1349,10 +1350,13 @@ void ivas_param_ism_dec_dequant_md_fx( Decoder_Struct *st_ivas ) { /* De-quantization */ + test(); IF( !( EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, IVAS_SID_5k2 ) || EQ_32( st_ivas->hDecoderConfig->ivas_total_brate, FRAME_NO_DATA ) ) ) { ivas_param_ism_dec_dequant_DOA_fx( st_ivas->hParamIsmDec, st_ivas->nchan_ism ); + ivas_param_ism_dec_dequant_powrat_fx( st_ivas->hParamIsmDec ); + st_ivas->hISMDTX.dtx_flag = 0; move16(); } @@ -1365,6 +1369,7 @@ void ivas_param_ism_dec_dequant_md_fx( return; } + /*-------------------------------------------------------------------------* * ivas_param_ism_dec_prepare_renderer_fx() * @@ -1372,12 +1377,12 @@ void ivas_param_ism_dec_dequant_md_fx( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_prepare_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const Word16 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const Word16 nCldfbSlots /* i : number of CLDFB slots in transport channels */ ) { - int16_t ch, nchan_transport, nchan_out, nchan_out_woLFE, i; - int16_t slot_idx, bin_idx; + Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i; + Word16 slot_idx, bin_idx; Word32 cx_diag_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 exp_cx_diag[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_DMX]; Word16 exp_real_tmp = 0, exp_imag_tmp = 0; diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 3112ad77a..01d559e2c 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1549,6 +1549,7 @@ ivas_error ivas_jbm_dec_tc_fx( * * Feed decoded transport channels and metadata to the IVAS JBM renderer routine *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_feed_tc_to_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ @@ -1571,7 +1572,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } Word16 n, n_render_timeslots; - push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + push_wmops( "ivas_jbm_dec_feed_tc_to_renderer" ); FOR( n = 0; n < MAX_CLDFB_DIGEST_CHANNELS; n++ ) { p_data_f_fx[n] = &data_f_fx[n][0]; @@ -1616,7 +1617,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) @@ -1633,7 +1634,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); @@ -1805,7 +1806,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_mc_paramupmix_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { @@ -1893,6 +1894,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( * * Principal IVAS JBM rendering routine *--------------------------------------------------------------------------*/ + ivas_error ivas_jbm_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesAsked, /* i : number of samples wanted */ @@ -2229,6 +2231,9 @@ ivas_error ivas_jbm_dec_render_fx( ivas_ism_render_sf_fx( st_ivas, st_ivas->renderer_type, p_output_fx, *nSamplesRendered ); /* add already rendered SBA part */ +#ifdef OBJ_EDITING_API + ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, st_ivas->hSbaIsmData->gain_bed_fx, nchan_out, st_ivas->nchan_ism, st_ivas->ism_mode, *nSamplesRendered ); +#else #ifdef OBJ_EDITING_API test(); IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) @@ -2267,6 +2272,7 @@ ivas_error ivas_jbm_dec_render_fx( { ivas_osba_stereo_add_channels_fx( p_tc_fx, p_output_fx, ONE_IN_Q11, nchan_out, st_ivas->nchan_ism, *nSamplesRendered ); } +#endif } ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_OSBA_AMBI ) || EQ_32( st_ivas->renderer_type, RENDERER_OSBA_LS ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { @@ -4523,20 +4529,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_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { Word16 n, n_render_timeslots, tmp, exp; - push_wmops( "ivas_jbm_dec_feed_tc_to_rendererer" ); + push_wmops( "ivas_dec_prepare_renderer" ); /* n_render_timeslots = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */ tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); @@ -4703,25 +4710,26 @@ void ivas_jbm_dec_prepare_renderer( test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_DIRAC ) ) { - Word16 num_objects; + Word16 nchan_transport_ism; /* Delay the signal to match CLDFB delay. Delay the whole buffer. */ - num_objects = 0; + nchan_transport_ism = 0; move16(); test(); test(); IF( ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { - num_objects = 1; + nchan_transport_ism = 1; move16(); } ELSE IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) { - num_objects = st_ivas->nchan_ism; + nchan_transport_ism = st_ivas->nchan_ism; move16(); } - FOR( n = 0; n < num_objects; n++ ) + + FOR( n = 0; n < nchan_transport_ism; n++ ) { test(); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) @@ -4748,7 +4756,7 @@ void ivas_jbm_dec_prepare_renderer( { IF( st_ivas->hMasaIsmData->masa_gain_is_edited ) { - FOR( n = 0; n < 2; n++ ) + FOR( n = 0; n < BINAURAL_CHANNELS; n++ ) { v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available ); // Q8 Scale_sig32( st_ivas->hTcBuffer->tc_fx[n], st_ivas->hTcBuffer->n_samples_available, Q3 ); // Q8 -> Q11 @@ -4766,7 +4774,7 @@ void ivas_jbm_dec_prepare_renderer( } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) { - ivas_mc_paramupmix_dec_digest_tc( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); + ivas_mc_paramupmix_dec_digest_tc_fx( st_ivas, (UWord8) n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) { diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index acfdab568..517482ff8 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1522,10 +1522,10 @@ void ivas_param_mc_dec_read_BS_fx( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_digest_tc_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - Word32 *transport_channels_f_fx[], - Word16 transport_f_e ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + Word32 *transport_channels_f_fx[], /* i : synthesized core-coder transport channels/DirAC output */ + const Word16 transport_f_e ) { PARAM_MC_DEC_HANDLE hParamMC; #ifdef OBJ_EDITING_API @@ -1538,6 +1538,7 @@ void ivas_param_mc_dec_digest_tc_fx( Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb; Word16 nchan_out_cov; #endif + /*CLDFB*/ hParamMC = st_ivas->hParamMC; @@ -1873,8 +1874,8 @@ void ivas_param_mc_dec_digest_tc_fx( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord8 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots /* i : number of CLDFB slots in transport channels */ ) { Word16 i; @@ -1953,6 +1954,7 @@ void ivas_param_mc_dec_prepare_renderer( hParamMC->hMetadataPMC->attackIndex = s_max( 0, add( hParamMC->hMetadataPMC->attackIndex, shr( sub( nCldfbSlots, DEFAULT_JBM_CLDFB_TIMESLOTS ), 1 ) ) ); move16(); } + /* adapt subframes */ hParamMC->num_slots = nCldfbSlots; move16(); @@ -1999,6 +2001,7 @@ void ivas_param_mc_dec_prepare_renderer( { CONTINUE; } + IF( is_next_band ) { ivas_dirac_dec_output_synthesis_cov_param_mc_collect_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport], @@ -2030,6 +2033,7 @@ void ivas_param_mc_dec_prepare_renderer( } } } + Word16 tmp_cx_e, tmp_cx_imag_e; /* map from complex input covariance to real values */ FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) @@ -2099,6 +2103,7 @@ void ivas_param_mc_dec_prepare_renderer( } } } + /* Cx for transport channels */ FOR( is_next_band = 0; is_next_band < 2; is_next_band++ ) { @@ -2118,9 +2123,7 @@ void ivas_param_mc_dec_prepare_renderer( cx_e = max_e; move16(); - /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/ - test(); test(); IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) ) @@ -2161,13 +2164,16 @@ void ivas_param_mc_dec_prepare_renderer( } } } + + return; } #endif + /*------------------------------------------------------------------------- - * ivas_param_mc_dec() + * ivas_param_mc_dec_render() * - * Parametric MC decoding process + * Parametric MC rendering process *------------------------------------------------------------------------*/ void ivas_param_mc_dec_render_fx( diff --git a/lib_dec/ivas_mc_paramupmix_dec_fx.c b/lib_dec/ivas_mc_paramupmix_dec_fx.c index dd26815bd..d28ba8328 100644 --- a/lib_dec/ivas_mc_paramupmix_dec_fx.c +++ b/lib_dec/ivas_mc_paramupmix_dec_fx.c @@ -206,10 +206,10 @@ void ivas_mc_paramupmix_dec_read_BS( * *------------------------------------------------------------------------*/ -void ivas_mc_paramupmix_dec_digest_tc( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels*/ - const Word16 nSamplesForRendering /* i : number of samples provided */ +void ivas_mc_paramupmix_dec_digest_tc_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + const Word16 nSamplesForRendering /* i : number of samples provided */ ) { MC_PARAMUPMIX_DEC_HANDLE hMCParamUpmix; diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 7cecc50d7..6c08d3faa 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -329,6 +329,69 @@ ivas_error ivas_osba_render_sf_fx( * *-------------------------------------------------------------------------*/ +#ifdef OBJ_EDITING_API +void ivas_osba_stereo_add_channels_fx( + Word32 *tc_fx[], /* i : transport channels */ + Word32 *output_fx[], /* i/o: output channels */ + const Word16 gain_bed_fx, /* i : gain bed value */ + const Word16 nchan_out, /* i : number of output channels */ + const Word16 nchan_ism, /* i : number of ISM channels */ + const Word16 ism_mode, /* i : ISM mode */ + const UWord16 n_samples_to_render /* i : output frame length per channel */ +) +{ + Word16 n, i; + + IF( EQ_16( ism_mode, ISM_SBA_MODE_DISC ) ) + { + Word32 gain = gain_bed_fx; + test(); + + // TODO: Enable gain editing feature (NE_32 ( gain, ONE_IN_Q_gain ) ) + test(); + IF( NE_32( gain, ONE_IN_Q29 ) && GT_32( gain, 0 ) ) + { + FOR( n = 0; n < nchan_out; n++ ) + { + FOR( i = 0; i < n_samples_to_render; i++ ) + { + Word32 tmp1 = Mpy_32_32( tc_fx[n + nchan_ism][i], gain ); // Q11 + Q29 - 31 = Q9 + tmp1 = L_shl( tmp1, 2 ); // Q9 --> Q11 + output_fx[n][i] = L_add_sat( output_fx[n][i], tmp1 ); // Q11 + } + } + } + ELSE + { + FOR( n = 0; n < nchan_out; n++ ) + { + FOR( n = 0; n < nchan_out; n++ ) + { + FOR( i = 0; i < n_samples_to_render; i++ ) + { + output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 + } + } + } + } + } + ELSE + { + FOR( n = 0; n < nchan_out; n++ ) + { + FOR( n = 0; n < nchan_out; n++ ) + { + FOR( i = 0; i < n_samples_to_render; i++ ) + { + output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 + } + } + } + } + + return; +} +#else void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ @@ -354,3 +417,4 @@ void ivas_osba_stereo_add_channels_fx( return; } +#endif diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 68188621f..b6129f3c7 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1095,7 +1095,10 @@ typedef struct decoder_config_structure Word16 Opt_ExternalOrientation; /* indicates whether external orientations are used */ Word16 Opt_dpid_on; /* indicates whether Directivity pattern option is used */ Word16 Opt_aeid_on; /* indicates whether Acoustic environment option is used */ - Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ +#ifdef OBJ_EDITING_COMMANDLINE + Word16 Opt_ObjEdit_on; /* indicates whether object editing option is used */ +#endif + Word16 Opt_tsm; /* indicates whether time scaling modification is activated */ IVAS_RENDER_FRAMESIZE render_framesize; Word16 Opt_delay_comp; /* flag indicating delay compensation active */ diff --git a/lib_dec/lib_dec.h b/lib_dec/lib_dec.h index 7957d1916..750d53d67 100644 --- a/lib_dec/lib_dec.h +++ b/lib_dec/lib_dec.h @@ -125,6 +125,9 @@ ivas_error IVAS_DEC_Configure( const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ const UWord16 acousticEnvironmentId, /* i : Acoustic environment ID */ +#ifdef OBJ_EDITING_COMMANDLINE + const bool objEditEnabled, /* i : enable object editing */ +#endif const bool delayCompensationEnabled /* i : enable delay compensation */ ); @@ -171,17 +174,17 @@ ivas_error IVAS_DEC_GetSamples( #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( - IVAS_DEC_HANDLE hIvasDec + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ ); #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index b6d608a25..18d8bcc49 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -107,10 +107,6 @@ struct IVAS_DEC UWord16 nSamplesFlushed; Word16 *flushbuffer; -#ifdef OBJ_EDITING_API - bool hasEditableParameters; - bool enableParameterEditing; -#endif bool hasBeenPreparedRendering; }; @@ -222,11 +218,9 @@ ivas_error IVAS_DEC_Open( // hIvasDec->flushbuffer = NULL; #endif hIvasDec->nSamplesFlushed = 0; -#ifdef OBJ_EDITING_API - hIvasDec->hasEditableParameters = false; - hIvasDec->enableParameterEditing = false; -#endif + move16(); hIvasDec->hasBeenPreparedRendering = false; + move16(); hIvasDec->mode = mode; move16(); @@ -393,6 +387,10 @@ 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; + move16(); +#endif move16(); move16(); move16(); @@ -455,12 +453,14 @@ void IVAS_DEC_Close( { free( ( *phIvasDec )->apaExecBuffer_fx ); } + #ifdef OBJ_EDITING_API IF( ( *phIvasDec )->flushbuffer != NULL ) { free( ( *phIvasDec )->flushbuffer ); } #endif + free( *phIvasDec ); *phIvasDec = NULL; phIvasDec = NULL; @@ -553,7 +553,10 @@ ivas_error IVAS_DEC_Configure( const Word16 non_diegetic_pan_gain_fx, /* i : non diegetic panning gain */ const bool dpidEnabled, /* i : enable directivity pattern option */ const UWord16 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; @@ -624,7 +627,6 @@ ivas_error IVAS_DEC_Configure( hDecoderConfig->Opt_delay_comp = (Word16) delayCompensationEnabled; hDecoderConfig->Opt_ExternalOrientation = enableExternalOrientation; hDecoderConfig->Opt_dpid_on = (Word16) dpidEnabled; - IF( NE_32( (Word32) acousticEnvironmentId, 65535 ) ) { hDecoderConfig->Opt_aeid_on = TRUE; @@ -633,6 +635,10 @@ ivas_error IVAS_DEC_Configure( { hDecoderConfig->Opt_aeid_on = FALSE; } +#ifdef OBJ_EDITING_COMMANDLINE + hDecoderConfig->Opt_ObjEdit_on = (Word16) objEditEnabled; +#endif + move16(); move16(); move16(); move16(); @@ -4292,6 +4298,16 @@ ivas_error IVAS_DEC_GetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + hIvasEditableParameters->num_obj = 0; + move16(); + + return IVAS_ERR_OK; + } +#endif + st_ivas = hIvasDec->st_ivas; ism_mode = st_ivas->ism_mode; @@ -4299,22 +4315,18 @@ ivas_error IVAS_DEC_GetEditableParameters( test(); test(); test(); - test(); +#ifdef NONBE_1217_INIT_OBJ_EDIT + IF( !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || + EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) || + EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) || + ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && GT_16( st_ivas->nchan_ism, 0 ) ) ) ) +#else IF( !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) || ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( ism_mode, ISM_MASA_MODE_DISC ) ) ) ) ) { return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Object editing no supported in this operation mode." ); } - -#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - hIvasEditableParameters->num_obj = 0; - move16(); - - return IVAS_ERR_OK; - } #endif hIvasEditableParameters->gain_bed_fx = ONE_IN_Q29; @@ -4328,7 +4340,7 @@ ivas_error IVAS_DEC_GetEditableParameters( IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { test(); - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + IF( EQ_32( ism_mode, ISM_MODE_DISC ) || EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { @@ -4374,16 +4386,21 @@ ivas_error IVAS_DEC_GetEditableParameters( move16(); } } + ELSE IF( EQ_32( ism_mode, ISM_MODE_NONE ) ) + { + hIvasEditableParameters->num_obj = 0; + move16(); + } ELSE { assert( 0 && "This should never happen!" ); } } #ifdef OMASA_OBJECT_EDITING - ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || st_ivas->ism_mode == ISM_MASA_MODE_DISC ) ) + ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( ism_mode, ISM_MASA_MODE_DISC ) ) ) { /* object editing possible only in two highest OMASA modes */ - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) + IF( EQ_32( ism_mode, ISM_MASA_MODE_DISC ) ) { FOR( obj = 0; obj < hIvasEditableParameters->num_obj; obj++ ) { @@ -4459,10 +4476,10 @@ ivas_error IVAS_DEC_SetEditableParameters( IVAS_EDITABLE_PARAMETERS hIvasEditableParameters ) { #ifdef OMASA_OBJECT_EDITING - Word16 dirac_read_idx; -#endif - + Word16 dirac_read_idx, obj; +#else Word16 obj; +#endif Decoder_Struct *st_ivas; ISM_MODE ism_mode; @@ -4472,6 +4489,13 @@ ivas_error IVAS_DEC_SetEditableParameters( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } +#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST + IF( !hIvasDec->hasBeenFedFirstGoodFrame ) + { + return IVAS_ERR_OK; + } +#endif + st_ivas = hIvasDec->st_ivas; ism_mode = st_ivas->ism_mode; @@ -4479,34 +4503,35 @@ ivas_error IVAS_DEC_SetEditableParameters( test(); test(); test(); +#ifdef NONBE_1217_INIT_OBJ_EDIT + IF( !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || + EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) || + EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) || + ( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && GT_16( st_ivas->nchan_ism, 0 ) ) ) ) +#else test(); test(); IF( !( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || ( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) || ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_32( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_32( ism_mode, ISM_MASA_MODE_DISC ) ) ) ) || EQ_32( 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." ); } -#ifdef NONBE_1293_CRASH_FIRST_FRAME_LOST - IF( !hIvasDec->hasBeenFedFirstGoodFrame ) - { - return IVAS_ERR_OK; - } -#endif -#ifdef DEBUGGING - assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); -#endif - test(); test(); test(); IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { test(); - IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) || EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + IF( EQ_32( ism_mode, ISM_MODE_DISC ) || EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { + +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif FOR( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { st_ivas->hIsmMetaData[obj]->edited_azimuth_fx = hIvasEditableParameters.ism_metadata[obj].azimuth_fx; @@ -4533,6 +4558,10 @@ ivas_error IVAS_DEC_SetEditableParameters( } ELSE IF( EQ_32( ism_mode, ISM_MODE_PARAM ) ) { + +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif FOR( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { #ifdef OBJ_EDITING_PARAMISM_BIN @@ -4574,17 +4603,27 @@ ivas_error IVAS_DEC_SetEditableParameters( move16(); #endif } + ELSE IF( EQ_32( ism_mode, ISM_MODE_NONE ) ) + { + IF( hIvasEditableParameters.num_obj != 0 ) + { + return IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED; + } + } ELSE { assert( 0 && "This should never happen!" ); } } #ifdef OMASA_OBJECT_EDITING - ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) ) + ELSE IF( EQ_16( st_ivas->ivas_format, MASA_ISM_FORMAT ) && ( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) || EQ_16( ism_mode, ISM_MASA_MODE_DISC ) ) ) { Word32 id_th; Word32 threshold_azi, threshold_ele; +#ifdef DEBUGGING + assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); +#endif FOR( obj = 0; obj < hIvasEditableParameters.num_obj; obj++ ) { IF( st_ivas->hMasaIsmData != NULL ) @@ -4604,7 +4643,7 @@ ivas_error IVAS_DEC_SetEditableParameters( new_ele = negate( new_ele ); } - IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + IF( EQ_16( ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { /* Handle MONO output */ IF( NE_16( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) ) @@ -4719,11 +4758,12 @@ ivas_error IVAS_DEC_SetEditableParameters( /*---------------------------------------------------------------------* * IVAS_DEC_PrepareRenderer( ) * - * Main function to decode to PCM data + * prepare IVAS renderer *---------------------------------------------------------------------*/ ivas_error IVAS_DEC_PrepareRenderer( - IVAS_DEC_HANDLE hIvasDec ) + IVAS_DEC_HANDLE hIvasDec /* i/o: IVAS decoder handle */ +) { test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) @@ -4736,7 +4776,7 @@ ivas_error IVAS_DEC_PrepareRenderer( IF( hIvasDec->hasBeenFedFirstGoodFrame || hIvasDec->isInitialized ) /* note: 'isInitialized' is related to EVS decoder */ #endif { - ivas_jbm_dec_prepare_renderer( hIvasDec->st_ivas ); + ivas_dec_prepare_renderer_fx( hIvasDec->st_ivas ); } hIvasDec->hasBeenPreparedRendering = true; @@ -4971,11 +5011,11 @@ ivas_error IVAS_DEC_VoIP_GetSamples( } #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; move16(); + return IVAS_ERR_OK; } #endif @@ -5006,6 +5046,7 @@ ivas_error IVAS_DEC_VoIP_GetSamples( Word16 nSamplesToRender, nSamplesRendered_loop; bool tmp; + /* decode TCs, do TSM and prepare the renderer */ test(); IF( !hIvasDec->isInitialized || hIvasDec->hasBeenFedFrame ) { @@ -5512,6 +5553,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_rend/ivas_objectRenderer_sources_fx.c b/lib_rend/ivas_objectRenderer_sources_fx.c index 781fe52ce..bc4f76f19 100644 --- a/lib_rend/ivas_objectRenderer_sources_fx.c +++ b/lib_rend/ivas_objectRenderer_sources_fx.c @@ -133,8 +133,9 @@ ivas_error TDREND_MIX_SRC_SetDir_fx( } #ifdef OBJ_EDITING_INTERFACE + /*-------------------------------------------------------------------* - * TDREND_MIX_SRC_SetSourceGain() + * TDREND_MIX_SRC_SetGain() * * Set source gain --------------------------------------------------------------------*/ @@ -149,6 +150,7 @@ ivas_error TDREND_MIX_SRC_SetGain( return IVAS_ERR_OK; } + #endif /*-------------------------------------------------------------------* @@ -705,6 +707,8 @@ static void TDREND_SRC_SPATIAL_SetGain( ) { Src_p->SrcRend_p->SrcGain_p_fx[0] = shl_sat( extract_h( Gain ), Q1 ); // TODO: Check incoming Q-value and fix this + + return; } #endif diff --git a/readme.txt b/readme.txt index b195e99c7..91ddd31f7 100644 --- a/readme.txt +++ b/readme.txt @@ -290,7 +290,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' @@ -306,6 +306,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 : Acoustic environment ID (number >= 0) for BINAURAL_ROOM_REVERB output config. +-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). @@ -326,7 +327,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) -- GitLab From afef1bd700556cefbd730d3b4062d789ecfd94ad Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 10:17:02 +0200 Subject: [PATCH 2/9] clang-format --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 01d559e2c..6577a31ce 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1617,7 +1617,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) @@ -1634,7 +1634,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); -- GitLab From 89c504002dd9cc2036f25b99cc9ef1722057b471 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 10:39:01 +0200 Subject: [PATCH 3/9] fix --- lib_com/ivas_prot_fx.h | 2 +- lib_com/options.h | 1 - lib_dec/ivas_ism_param_dec_fx.c | 9 +++++++-- lib_dec/ivas_jbm_dec_fx.c | 36 ++++++++++++++++++++++----------- lib_dec/ivas_osba_dec_fx.c | 2 +- 5 files changed, 33 insertions(+), 17 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index a6c21e1d6..bd2760d34 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -3928,7 +3928,7 @@ ivas_error ivas_osba_render_sf_fx( void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ - const Word16 gain_bed_fx, /* i : gain bed value Q11 */ + const Word32 gain_bed_fx, /* i : gain bed value Q11 */ const Word16 nchan_out, /* i : number of output channels */ const Word16 nchan_ism, /* i : number of ISM channels */ const Word16 ism_mode, /* i : ISM mode */ diff --git a/lib_com/options.h b/lib_com/options.h index 5872c5a3d..ae33093a8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -129,7 +129,6 @@ #ifdef OBJ_EDITING_API #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) #define TMP_FIX_OMASA_SR_BE // temporary fix to keep OMASA split-rendering BE - #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 */ diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index 1a1a376e8..50e2ee439 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -994,8 +994,10 @@ void ivas_ism_dec_digest_tc_fx( IF( EQ_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_STEREO ) ) { #ifdef OBJ_EDITING_API - Word16 gains_fx[2]; + Word16 gains_fx[CPE_CHANNELS]; + ivas_ism_get_stereo_gains_fx( (Word16) L_shr( st_ivas->hIsmMetaData[i]->azimuth_fx, 22 ), (Word16) L_shr( st_ivas->hIsmMetaData[i]->elevation_fx, 22 ), &gains_fx[0], &gains_fx[1] ); + st_ivas->hIsmRendererData->gains_fx[i][0] = L_shr( L_deposit_h( gains_fx[0] ), 1 ); // Q31 -> Q30 move32(); st_ivas->hIsmRendererData->gains_fx[i][1] = L_shr( L_deposit_h( gains_fx[1] ), 1 ); // Q31 -> Q30 @@ -1052,6 +1054,7 @@ void ivas_ism_dec_digest_tc_fx( { azimuth_fx = L_shl( azimuth_fx, Q22 ); // Q22 elevation_fx = L_shl( elevation_fx, Q22 ); // Q22 + efap_determine_gains_fx( st_ivas->hEFAPdata, st_ivas->hIsmRendererData->gains_fx[i], azimuth_fx, elevation_fx, EFAP_MODE_EFAP ); #ifdef OBJ_EDITING_API // TODO: align Q values properly @@ -1070,7 +1073,9 @@ void ivas_ism_dec_digest_tc_fx( /*get HOA gets for direction (ACN/SN3D)*/ Word16 azi = shr( extract_h( st_ivas->hIsmMetaData[i]->azimuth_fx ), 22 - 16 ); // Q0 Word16 ele = shr( extract_h( st_ivas->hIsmMetaData[i]->elevation_fx ), 22 - 16 ); // Q0 + ivas_dirac_dec_get_response_fx( azi, ele, st_ivas->hIsmRendererData->gains_fx[i], st_ivas->hIntSetup.ambisonics_order, Q30 ); + #ifdef OBJ_EDITING_API // TODO: Align Q-values IF( NE_32( st_ivas->hIsmMetaData[i]->edited_gain_fx, ONE_IN_Q29 ) ) @@ -2004,6 +2009,7 @@ void ivas_param_ism_dec_render_fx( * * *-------------------------------------------------------------------------*/ + void ivas_param_ism_params_to_masa_param_mapping_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -2025,7 +2031,6 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( Word32 ivas_total_brate; #endif - hParamIsmDec = st_ivas->hParamIsmDec; move16(); hSpatParamRendCom = st_ivas->hSpatParamRendCom; diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 6577a31ce..b920ccee8 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -198,7 +198,9 @@ ivas_error ivas_jbm_dec_tc_fx( move16(); } } + ivas_ism_dtx_limit_noise_energy_for_near_silence_fx( st_ivas->hSCE, st_ivas->hISMDTX.sce_id_dtx, st_ivas->nchan_transport, Q_cngNoiseLevel ); + #ifdef OBJ_EDITING_API ivas_param_ism_dec_dequant_md_fx( st_ivas ); #endif @@ -209,6 +211,7 @@ ivas_error ivas_jbm_dec_tc_fx( { return error; } + #ifdef OBJ_EDITING_API ivas_param_ism_dec_dequant_md_fx( st_ivas ); #endif @@ -1617,7 +1620,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) @@ -1634,7 +1637,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); @@ -4538,10 +4541,10 @@ void ivas_jbm_masa_sf_to_sf_map( *--------------------------------------------------------------------------*/ void ivas_dec_prepare_renderer_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - Word16 n, n_render_timeslots, tmp, exp; + Word16 n, n_render_timeslots, tmp, exp, shift; push_wmops( "ivas_dec_prepare_renderer" ); @@ -4549,7 +4552,7 @@ void ivas_dec_prepare_renderer_fx( tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); n_render_timeslots = shr( tmp, sub( 15, exp ) ); // Q0 - + test(); IF( EQ_16( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); @@ -4571,6 +4574,7 @@ void ivas_dec_prepare_renderer_fx( /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) { + test(); test(); test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) @@ -4593,7 +4597,7 @@ void ivas_dec_prepare_renderer_fx( { IF( st_ivas->hSCE[0] ) { - Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); IF( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); @@ -4601,11 +4605,11 @@ void ivas_dec_prepare_renderer_fx( scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift) st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { ivas_ism_dec_digest_tc_fx( st_ivas ); @@ -4614,6 +4618,8 @@ void ivas_dec_prepare_renderer_fx( test(); test(); test(); + test(); + test(); /* delay the objects here for all renderers where it is needed */ IF( ( @@ -4641,7 +4647,7 @@ void ivas_dec_prepare_renderer_fx( IF( st_ivas->hSCE[0] ) { - Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); @@ -4658,7 +4664,7 @@ void ivas_dec_prepare_renderer_fx( IF( st_ivas->hSCE[0] ) { - Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); @@ -4666,6 +4672,7 @@ void ivas_dec_prepare_renderer_fx( scale_sig32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN, shift ); // Q(31-cngNoiseLevelExp+shift) st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } @@ -4675,6 +4682,7 @@ void ivas_dec_prepare_renderer_fx( IF( EQ_32( st_ivas->renderer_type, RENDERER_OMASA_MIX_EXT ) || EQ_32( st_ivas->renderer_type, RENDERER_OMASA_OBJECT_EXT ) ) { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); + IF( st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots ); @@ -4690,7 +4698,7 @@ void ivas_dec_prepare_renderer_fx( IF( st_ivas->hSCE[0] ) { - Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); @@ -4699,6 +4707,7 @@ void ivas_dec_prepare_renderer_fx( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); move16(); } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) @@ -4750,6 +4759,7 @@ void ivas_dec_prepare_renderer_fx( delay_signal32_fx( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available, st_ivas->hMasaIsmData->delayBuffer_fx[n], st_ivas->hMasaIsmData->delayBuffer_size ); // TODO: check if tis is a bug in main already } + #ifdef OMASA_OBJECT_EDITING test(); IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) @@ -4784,6 +4794,7 @@ void ivas_dec_prepare_renderer_fx( Word16 nchan_out_cov; test(); test(); + IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); @@ -4811,7 +4822,7 @@ void ivas_dec_prepare_renderer_fx( scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1 ); // Q(31-1+1) - Word16 shift; + shift; FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ ) { shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport ) ); @@ -4829,7 +4840,7 @@ void ivas_dec_prepare_renderer_fx( { IF( st_ivas->hSCE[0] ) { - Word16 shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); + shift = getScaleFactor32( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel, FFTCLDFBLEN ); if ( LT_16( sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ), 4 ) ) { shift = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, 4 ); @@ -4838,6 +4849,7 @@ void ivas_dec_prepare_renderer_fx( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp = sub( st_ivas->hSCE[0]->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp, shift ); move16(); } + ivas_sba_dec_digest_tc_fx( st_ivas, n_render_timeslots, st_ivas->hTcBuffer->n_samples_available ); } } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 6c08d3faa..92d359a27 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -333,7 +333,7 @@ ivas_error ivas_osba_render_sf_fx( void ivas_osba_stereo_add_channels_fx( Word32 *tc_fx[], /* i : transport channels */ Word32 *output_fx[], /* i/o: output channels */ - const Word16 gain_bed_fx, /* i : gain bed value */ + const Word32 gain_bed_fx, /* i : gain bed value */ const Word16 nchan_out, /* i : number of output channels */ const Word16 nchan_ism, /* i : number of ISM channels */ const Word16 ism_mode, /* i : ISM mode */ -- GitLab From 13c8236689f9bf4b5f7c06ef25c16365aa9f15c9 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 10:50:01 +0200 Subject: [PATCH 4/9] clang-format --- lib_dec/ivas_jbm_dec_fx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index b920ccee8..de9461d25 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1620,7 +1620,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) @@ -1637,7 +1637,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); -- GitLab From 59025d6db6d03f617d270940fb8f2b8572f112a7 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 10:57:13 +0200 Subject: [PATCH 5/9] fix --- lib_dec/ivas_jbm_dec_fx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index de9461d25..76cf62ce2 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1620,7 +1620,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) @@ -1637,7 +1637,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); @@ -4822,7 +4822,6 @@ void ivas_dec_prepare_renderer_fx( scale_sig32( st_ivas->hParamMC->proto_matrix_int_fx, st_ivas->hParamMC->proto_matrix_int_len, 1 ); // Q(31-1+1) - shift; FOR( Word16 param_band_idx = 0; param_band_idx < st_ivas->hParamMC->num_param_bands_synth; param_band_idx++ ) { shift = getScaleFactor32( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx], s_min( st_ivas->hParamMC->h_output_synthesis_cov_state.cx_old_len, nchan_transport * nchan_transport ) ); -- GitLab From 571a5a882708107aae4130d945e90df75d57f710 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 11:02:28 +0200 Subject: [PATCH 6/9] clang-format --- lib_dec/ivas_jbm_dec_fx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 76cf62ce2..045e4b110 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1620,7 +1620,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) + IF( EQ_16( st_ivas->ivas_format, ISM_FORMAT ) ) { /* Rendering */ IF( EQ_16( st_ivas->ism_mode, ISM_MODE_PARAM ) ) @@ -1637,7 +1637,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( } ELSE #endif - IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + IF( EQ_16( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_f_fx, Q11 ); @@ -4744,7 +4744,6 @@ void ivas_dec_prepare_renderer_fx( IF( EQ_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) { #ifdef OMASA_OBJECT_EDITING - v_multc_fx_16( st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], OMASA_TDREND_MATCHING_GAIN_FX, st_ivas->hTcBuffer->tc_fx[CPE_CHANNELS + n], st_ivas->hTcBuffer->n_samples_available ); IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) @@ -4792,9 +4791,9 @@ void ivas_dec_prepare_renderer_fx( move16(); Word16 nchan_out_transport = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); Word16 nchan_out_cov; + test(); test(); - IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) { nchan_out_cov = add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ); -- GitLab From 9cdaf697157bac701cda64ea177559ffd764ec15 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 12:03:17 +0200 Subject: [PATCH 7/9] fix --- lib_com/ivas_prot_fx.h | 4 ++-- lib_dec/ivas_mc_param_dec_fx.c | 8 ++++---- lib_dec/lib_dec_fx.c | 4 +--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index bd2760d34..4c6d7cb49 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5163,8 +5163,8 @@ void ivas_param_mc_dec_close_fx( void ivas_param_mc_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ - Word32 *transport_channels_f_fx[], /* i : synthesized core-coder transport channels/DirAC output */ - const Word16 transport_f_e + Word32 *p_data_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const Word16 transport_f_e ); #ifdef OBJ_EDITING_API diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 517482ff8..8741769c8 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1522,9 +1522,9 @@ void ivas_param_mc_dec_read_BS_fx( *------------------------------------------------------------------------*/ void ivas_param_mc_dec_digest_tc_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord8 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ - Word32 *transport_channels_f_fx[], /* i : synthesized core-coder transport channels/DirAC output */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + Word32 *p_data_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ const Word16 transport_f_e ) { PARAM_MC_DEC_HANDLE hParamMC; @@ -1671,7 +1671,7 @@ void ivas_param_mc_dec_digest_tc_fx( { qout = transport_f_e; move16(); - cldfbAnalysis_ts_fx_fixed_q( &( transport_channels_f_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); + cldfbAnalysis_ts_fx_fixed_q( &( p_data_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 18d8bcc49..285950ee3 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -4528,7 +4528,6 @@ ivas_error IVAS_DEC_SetEditableParameters( test(); IF( EQ_32( ism_mode, ISM_MODE_DISC ) || EQ_32( ism_mode, ISM_SBA_MODE_DISC ) ) { - #ifdef DEBUGGING assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); #endif @@ -4558,7 +4557,6 @@ ivas_error IVAS_DEC_SetEditableParameters( } ELSE IF( EQ_32( ism_mode, ISM_MODE_PARAM ) ) { - #ifdef DEBUGGING assert( hIvasEditableParameters.num_obj == st_ivas->nchan_ism ); #endif @@ -4605,7 +4603,7 @@ ivas_error IVAS_DEC_SetEditableParameters( } ELSE IF( EQ_32( ism_mode, ISM_MODE_NONE ) ) { - IF( hIvasEditableParameters.num_obj != 0 ) + IF( NE_16( hIvasEditableParameters.num_obj, 0 ) ) { return IVAS_ERR_OBJECTS_EDITING_NOT_SUPPORTED; } -- GitLab From 4fb24350abc3f5d40a7e51576d5234f0d8960e39 Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 12:23:37 +0200 Subject: [PATCH 8/9] fix --- apps/decoder.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/decoder.c b/apps/decoder.c index 8cca8af76..24aa2d162 100644 --- a/apps/decoder.c +++ b/apps/decoder.c @@ -3401,9 +3401,7 @@ static void do_object_editing_fx( if ( !editableParameters->ism_metadata[obj_idx].non_diegetic_flag ) { editableParameters->ism_metadata[obj_idx].elevation_fx = 0; - // TODO: verify Q-format - // editableParameters.ism_metadata[obj_idx].azimuth_fx = (Word32) ( ( start_angle + (float) non_diegetic_obj_idx * angle_inc ) * powf( 2.0f, 22.0f ) ); - editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) ( start_angle + (Word32) non_diegetic_obj_idx * angle_inc * 4194304 /* Q22 */ ); + editableParameters->ism_metadata[obj_idx].azimuth_fx = (Word32) ( ( start_angle + (float) non_diegetic_obj_idx * angle_inc ) * 4194304 /* Q22 */ ); non_diegetic_obj_idx++; } } @@ -3412,9 +3410,7 @@ static void do_object_editing_fx( /* breakover object gains */ for ( obj_idx = 0; obj_idx < editableParameters->num_obj; obj_idx++ ) { - // TODO: verify Q-format - // editableParameters.ism_metadata[obj_idx].gain_fx = (Word32) ( ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f ) * powf( 2.0f, 29.0f ) ); - editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f * 536870912 /*Q29*/ ); + editableParameters->ism_metadata[obj_idx].gain_fx = (Word32) ( ( 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f ) * 536870912 /*Q29*/ ); } editableParameters->gain_bed_fx = ( 1 << 28 ); // 0.5 in Q29 -- GitLab From cc82ba60861d6311a6866f6693edf24b29e68e0e Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 20 Oct 2025 12:51:29 +0200 Subject: [PATCH 9/9] fix --- lib_com/ivas_ism_com_fx.c | 8 ++++++++ lib_com/ivas_prot_fx.h | 4 ++-- lib_dec/ivas_init_dec_fx.c | 3 ++- lib_dec/ivas_omasa_dec_fx.c | 6 ++++-- lib_dec/ivas_osba_dec_fx.c | 14 ++++---------- lib_dec/lib_dec_fx.c | 9 +++++---- lib_rend/ivas_dirac_dec_binaural_functions_fx.c | 6 +----- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib_com/ivas_ism_com_fx.c b/lib_com/ivas_ism_com_fx.c index 8514fb9c2..385e680bb 100644 --- a/lib_com/ivas_ism_com_fx.c +++ b/lib_com/ivas_ism_com_fx.c @@ -472,13 +472,21 @@ void ivas_ism_reset_metadata( #ifdef OBJ_EDITING_API hIsmMeta->edited_gain_fx = ONE_IN_Q29; + move32(); hIsmMeta->edited_azimuth_fx = 0; + move32(); hIsmMeta->edited_elevation_fx = 0; + move32(); hIsmMeta->edited_pitch_fx = 0; + move32(); hIsmMeta->edited_yaw_fx = 0; + move32(); hIsmMeta->edited_radius_fx = ONE_IN_Q9; + move32(); hIsmMeta->gain_fx = ONE_IN_Q29; + move32(); hIsmMeta->non_diegetic_flag = 0; + move16(); #endif return; diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 4c6d7cb49..dce0bac13 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -5169,8 +5169,8 @@ void ivas_param_mc_dec_digest_tc_fx( #ifdef OBJ_EDITING_API void ivas_param_mc_dec_prepare_renderer( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord8 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord8 nCldfbSlots /* i : number of CLFBS slots in the transport channels */ ); #endif diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 3c921766a..2d9943319 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -2160,11 +2160,12 @@ ivas_error ivas_init_decoder_fx( } reset_indices_dec( st_ivas->hSCE[0]->hCoreCoder[0] ); + #ifndef OMASA_OBJECT_EDITING IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { #endif - if ( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_ism_metadata_dec_create_fx( st_ivas, st_ivas->nchan_ism, NULL ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index bc822cd71..0285b724e 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -316,7 +316,7 @@ ivas_error ivas_omasa_data_open_fx( { MASA_ISM_DATA_HANDLE hMasaIsmData; #ifdef OMASA_OBJECT_EDITING - Word16 ch; + Word16 ch, band_idx; #else Word16 ch, bin; #endif @@ -328,7 +328,7 @@ ivas_error ivas_omasa_data_open_fx( } #ifdef OMASA_OBJECT_EDITING - FOR( Word16 band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) + FOR( band_idx = 0; band_idx < MASA_FREQUENCY_BANDS; band_idx++ ) { FOR( ch = 0; ch < 2; ch++ ) { @@ -1205,6 +1205,7 @@ void ivas_omasa_dirac_rend_jbm_fx( FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { Copy32( &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] ) @@ -1214,6 +1215,7 @@ void ivas_omasa_dirac_rend_jbm_fx( } #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_fx.c b/lib_dec/ivas_osba_dec_fx.c index 92d359a27..a5d5065be 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -365,12 +365,9 @@ void ivas_osba_stereo_add_channels_fx( { FOR( n = 0; n < nchan_out; n++ ) { - FOR( n = 0; n < nchan_out; n++ ) + FOR( i = 0; i < n_samples_to_render; i++ ) { - FOR( i = 0; i < n_samples_to_render; i++ ) - { - output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 - } + output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 } } } @@ -379,12 +376,9 @@ void ivas_osba_stereo_add_channels_fx( { FOR( n = 0; n < nchan_out; n++ ) { - FOR( n = 0; n < nchan_out; n++ ) + FOR( i = 0; i < n_samples_to_render; i++ ) { - FOR( i = 0; i < n_samples_to_render; i++ ) - { - output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 - } + output_fx[n][i] = L_add_sat( output_fx[n][i], tc_fx[n + nchan_ism][i] ); // Q11 } } } diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 285950ee3..b6e3ee48b 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -1574,8 +1574,8 @@ ivas_error IVAS_DEC_GetSplitBinauralBitstream( { return error; } -#endif +#endif FOR( i = 0; i < MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS; i++ ) { FOR( j = 0; j < CLDFB_NO_COL_MAX; j++ ) @@ -2447,11 +2447,9 @@ ivas_error IVAS_DEC_GetObjectMetadata( metadata->azimuth_fx = hIsmMeta->edited_azimuth_fx; metadata->elevation_fx = hIsmMeta->edited_elevation_fx; metadata->radius_fx = hIsmMeta->edited_radius_fx; - metadata->yaw_fx = hIsmMeta->edited_yaw_fx; metadata->pitch_fx = hIsmMeta->edited_pitch_fx; metadata->spread_fx = 0; - metadata->gainFactor_fx = hIsmMeta->edited_gain_fx; metadata->non_diegetic_flag = hIsmMeta->non_diegetic_flag; } @@ -4441,6 +4439,8 @@ ivas_error IVAS_DEC_GetEditableParameters( { hIvasEditableParameters->ism_metadata[obj].azimuth_fx = L_shl( L_deposit_l( st_ivas->hMasaIsmData->azimuth_ism_fx[obj][dirac_read_idx] ), Q22 ); hIvasEditableParameters->ism_metadata[obj].elevation_fx = L_shl( L_deposit_l( st_ivas->hMasaIsmData->elevation_ism_fx[obj][dirac_read_idx] ), Q22 ); + move32(); + move32(); hIvasEditableParameters->ism_metadata[obj].yaw_fx = st_ivas->hIsmMetaData[obj]->yaw_fx; hIvasEditableParameters->ism_metadata[obj].pitch_fx = st_ivas->hIsmMetaData[obj]->pitch_fx; @@ -4629,6 +4629,7 @@ ivas_error IVAS_DEC_SetEditableParameters( /* copy relevant fields also to OMASA structs, but only if the value has been changed. original values are in st_ivas->hIsmMetaData */ /* first, need to convert float values to ints used internally */ Word16 new_azi, new_ele; + new_azi = extract_l( L_shr( L_add( L_abs( hIvasEditableParameters.ism_metadata[obj].azimuth_fx ), 2097152 ), Q22 ) ); // Q22->Q0 IF( LT_32( hIvasEditableParameters.ism_metadata[obj].azimuth_fx, 0 ) ) { @@ -4652,6 +4653,7 @@ ivas_error IVAS_DEC_SetEditableParameters( { dirac_read_idx = 0; } + move16(); /* determine thresholds for detecting object metadata edit for direction based on quantization resolution of the spatial direction parameters. * these depend from the number of bits used to transmit the directions, @@ -5074,7 +5076,6 @@ ivas_error IVAS_DEC_VoIP_GetSamples( /* check if we still need to prepare the renderer */ IF( hIvasDec->hasBeenPreparedRendering == false ) { - IF( NE_32( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ), IVAS_ERR_OK ) ) { return error; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index e6c8df704..9d5302d1d 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -5379,6 +5379,7 @@ Word16 configure_reqularization_factor_fx( return reqularizationFactor; } + #ifdef OMASA_OBJECT_EDITING /*-------------------------------------------------------------------* * ivas_omasa_preProcessStereoTransportsForEditedObjects() @@ -5867,7 +5868,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } } - /* Perform the processing in frequency bands */ FOR( band_idx = 0; band_idx < max_band; band_idx++ ) { @@ -6157,7 +6157,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( { ratioAccNew = L_add( ratioAccNew, L_shr( ratio, 3 ) ); // Q27 } - #ifdef OBJ_EDITING_PARAMISM_BIN } #endif @@ -6186,7 +6185,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( move32(); } - /* New target total energy ratio divider */ IF( ratioAccNew > 0 ) { @@ -6263,7 +6261,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } } - /* Direction editing */ /* Determine new energetic values after gaining */ totalTargetEne = L_add( totalTargetEneCh[0], totalTargetEneCh[1] ); // SubQ @@ -6528,7 +6525,6 @@ void ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( } } - test(); IF( hMasaIsmData->preprocEneTarget_fx[band_idx] > 0 && hMasaIsmData->preprocEneRealized_fx[band_idx] > 0 ) { -- GitLab