Commit 3e63f4d6 authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Merge branch '2134-ref-PortMr1769-from-float-fix-issues-in-obj_editing' into 'ivas-float-update'

Port MR1769 from float to FLP-ref - Fix issues in OBJ_EDITING

See merge request !2417
parents 86e1472a 7936431d
Loading
Loading
Loading
Loading
+102 −61
Original line number Diff line number Diff line
@@ -56,11 +56,7 @@
#include "debug.h"
#endif
#include "wmc_auto.h"
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_EXAMPLE
#include <math.h>
#endif
#endif


#define WMC_TOOL_SKIP

@@ -157,7 +153,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

@@ -196,6 +192,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()
@@ -438,8 +438,13 @@ int main(
    uint16_t aeID = arg.aeSequence.count > 0 ? arg.aeSequence.pID[0] : 65535;

#ifdef LIB_DEC_REVISION
#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,
                                       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,
                                       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,
                                       arg.dpidEnabled, aeID, arg.delayCompensationEnabled ) ) != IVAS_ERR_OK )
@@ -1025,7 +1030,8 @@ static bool parseCmdlIVAS_dec(
    {
        arg->directivityPatternId[i] = 65535;
    }
#ifdef OBJ_EDITING_EXAMPLE

#ifdef OBJ_EDITING_COMMANDLINE
    arg->objEditEnabled = false;
#endif

@@ -1557,7 +1563,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;
@@ -1771,13 +1777,13 @@ static void usage_dec( void )
    fprintf( stdout, "                      ID and duration pairs, where duration is specified in frames\n" );
#endif
    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 <folder>      : specify subfolder name for debug output\n" );
@@ -2170,11 +2176,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
@@ -2532,62 +2533,29 @@ 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;
                    }

                    /* 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++;
                            }
                        }
                        return error;
                    }

                    /* 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;
                    }
                    /* Do object metadata editing here ... */
#ifdef OBJ_EDITING_EXAMPLE
                    do_object_editing( &editableParameters );

                    editableParameters.gain_bed = 0.5f;
#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
@@ -2597,7 +2565,6 @@ static ivas_error decodeG192(
                    fprintf( stderr, "\nError: could not prepare the renderer: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#endif
            }

            if ( isSplitRend )
@@ -2619,7 +2586,7 @@ static ivas_error decodeG192(
                if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( 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;
@@ -3485,9 +3452,29 @@ static ivas_error decodeVoIP(
            }

#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;
                }
            }
#endif
        } /* while ( nSamplesRendered < nOutSamples ) */
@@ -3780,6 +3767,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

/*---------------------------------------------------------------------*
+1 −0
Original line number Diff line number Diff line
@@ -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

+7 −0
Original line number Diff line number Diff line
@@ -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,
@@ -255,6 +258,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:
+22 −14
Original line number Diff line number Diff line
@@ -854,7 +854,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
@@ -1074,11 +1074,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
@@ -1146,18 +1141,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         */
    const uint16_t nCldfbSlots                                  /* i  : number of CLDFB slots in transport channels */
);
#endif

@@ -3842,7 +3837,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                      */
);

@@ -3912,14 +3907,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 *p_data_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     */
    const uint8_t nCldfbSlots                                   /* i  : number of CLDFB slots in transport channels         */
);
#endif

@@ -5638,6 +5633,17 @@ 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         */
);
#else
void ivas_osba_stereo_add_channels(
    float *tc_f[],                                              /* i  : transport channels                      */
    float *output_f[],                                          /* i/o: output channels                         */
@@ -5646,6 +5652,7 @@ void ivas_osba_stereo_add_channels(
    const int16_t nchan_ism,                                    /* i  : number of ISM channels                  */
    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                   */
@@ -5656,6 +5663,7 @@ ISM_MODE ivas_osba_ism_mode_select(
	const int16_t nchan_ism                                     /* i  : number of input ISM's   */
);


/*----------------------------------------------------------------------------------*
* OMASA prototypes
*---------------------------------------------------------------------------------*/
+7 −4
Original line number Diff line number Diff line
@@ -213,10 +213,13 @@
#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
#endif
#define OBJ_EDITING_COMMANDLINE                         /* obj editing command-line option */
#define OBJ_EDITING_EXAMPLE                             /* obj editing example code in decoder.c */
#endif
#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 */
#define NONBE_1217_INIT_OBJ_EDIT                        /* VA: issue 1217: do object editing only when objects metadata is available */
#endif

/* #################### End BASOP porting switches ############################ */

Loading