Commit 8c3578cb authored by vaclav's avatar vaclav
Browse files

port OBJ_EDITING_API + introduce FIX_HRTF_LOAD_API

parent 6ded5dc7
Loading
Loading
Loading
Loading
Loading
+107 −5
Original line number Diff line number Diff line
@@ -56,7 +56,11 @@
#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

@@ -2259,6 +2263,11 @@ 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

    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
@@ -2597,6 +2606,82 @@ static ivas_error decodeG192(
                    }
                }
#endif

#ifdef FIX_HRTF_LOAD_API
                /* decode transport channels, do TSM and feed to renderer */
                if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK )
                {
                    return error;
                }

#endif
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_EXAMPLE
                if ( arg.objEditEnabled )
                {

                    /* Do object info editing here */
                    /* get object parameters */
                    if ( ( error = IVAS_DEC_GetEditableParameters( hIvasDec, &editableParameters ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError: could not get the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }

                    /* edit object parameters...*/

                    /* put the objects equally spaced at the horizontal plane */
                    /* and play a little bit with the gains... */
                    int16_t obj_idx, non_diegetic_obj_idx;
                    int16_t num_nondiegetic_objects;

                    num_nondiegetic_objects = 0;
                    for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ )
                    {
                        if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag )
                        {
                            num_nondiegetic_objects++;
                        }
                    }
                    if ( num_nondiegetic_objects )
                    {
                        float start_angle, angle_inc;
                        angle_inc = 360.0f / (float) num_nondiegetic_objects;
                        start_angle = angle_inc / 2.0f;
                        for ( obj_idx = 0, non_diegetic_obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ )
                        {
                            if ( !editableParameters.ism_metadata[obj_idx].non_diegetic_flag )
                            {
                                editableParameters.ism_metadata[obj_idx].elevation = 0.0f;
                                editableParameters.ism_metadata[obj_idx].azimuth = start_angle + (float) non_diegetic_obj_idx * angle_inc;
                                non_diegetic_obj_idx++;
                            }
                        }
                    }

                    /* breakover object gains */
                    for ( obj_idx = 0; obj_idx < editableParameters.num_obj; obj_idx++ )
                    {
                        editableParameters.ism_metadata[obj_idx].gain = 0.5f + (float) ( ( frame + obj_idx * 50 ) % 250 ) / 250.0f;
                    }

                    editableParameters.gain_bed = 0.5f;

                    /* set new object parameters*/
                    if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nError: could not set the editable parameters: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
                }
#endif
                /* Do the final preparations needed for rendering */
                if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nError: could not prepare the renderer: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#endif
            }

            if ( isSplitRend )
@@ -3153,6 +3238,9 @@ static ivas_error decodeVoIP(
    int16_t nOutSamples = 0;
#ifdef FIX_CREND_SIMPLIFY_CODE
    bool bitstreamReadDone = false;
#ifdef OBJ_EDITING_API
    bool parameterAvailableForEditing = false;
#endif
    uint16_t nSamplesRendered;
#endif

@@ -3444,13 +3532,21 @@ static ivas_error decodeVoIP(
#endif
#ifdef SUPPORT_JBM_TRACEFILE
#ifdef FIX_CREND_SIMPLIFY_CODE
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered ) ) != IVAS_ERR_OK )
#ifdef OBJ_EDITING_API
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, &parameterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef FIX_CREND_SIMPLIFY_CODE
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone ) ) != IVAS_ERR_OK )
#ifdef OBJ_EDITING_API
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, &parameterAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK )
#else
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &bitstreamReadDone, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#else
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
@@ -3485,9 +3581,15 @@ static ivas_error decodeVoIP(
                }
            }
#endif
#ifdef FIX_HRTF_LOAD
#ifdef OBJ_EDITING_API
            if ( parameterAvailableForEditing == true )
            {
                /* do the object editing here */
            }
#endif
#ifdef FIX_HRTF_LOAD
        } /* while ( nSamplesRendered < nOutSamples ) */
#endif

        /* write JBM Offset file entry */
        if ( jbmOffsetWriter != NULL )
+12 −0
Original line number Diff line number Diff line
@@ -128,9 +128,21 @@ typedef struct _IVAS_ISM_METADATA
    float yaw;
    float pitch;
    int16_t non_diegetic_flag;
#ifdef OBJ_EDITING_API
    float gain;
#endif

} IVAS_ISM_METADATA;

#ifdef OBJ_EDITING_API
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

typedef struct
{
    float w, x, y, z;
+11 −0
Original line number Diff line number Diff line
@@ -418,6 +418,17 @@ void ivas_ism_reset_metadata(
    hIsmMeta->ism_metadata_flag = 0;
    hIsmMeta->non_diegetic_flag = 0;

#ifdef OBJ_EDITING_API
    hIsmMeta->edited_gain = 1.0f;
    hIsmMeta->edited_azimuth = 0.0f;
    hIsmMeta->edited_elevation = 0.0f;
    hIsmMeta->edited_pitch = 0.0f;
    hIsmMeta->edited_yaw = 0.0f;
    hIsmMeta->edited_radius = 1.0f;
    hIsmMeta->gain = 1.0f;
    hIsmMeta->non_diegetic_flag = 0;
#endif

    return;
}

+29 −0
Original line number Diff line number Diff line
@@ -864,6 +864,12 @@ void ivas_jbm_dec_feed_tc_to_renderer(
    float *data                                                 /* i/o: transport channels/output synthesis signal                  */
);

#ifdef OBJ_EDITING_API
void ivas_jbm_dec_prepare_renderer(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                                      */
);
#endif

ivas_error ivas_jbm_dec_set_discard_samples(
    Decoder_Struct *st_ivas                                     /* i/o: main IVAS decoder structre                                  */
);
@@ -1073,6 +1079,11 @@ 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
@@ -1150,6 +1161,17 @@ void ivas_param_ism_dec_digest_tc(
    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 
);

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         */
);
#endif

void ivas_ism_param_dec_tc_gain_ajust(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                         */
    const uint16_t nSamples,                                    /* i  : number of samples to be compensate          */
@@ -3911,6 +3933,13 @@ void ivas_param_mc_dec_digest_tc(
    float *transport_channels_f[]                               /* i  : 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     */
);
#endif

void ivas_param_mc_dec_render(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                                 */
    const uint16_t nSamplesAsked,                               /* i  : number of CLDFB slots requested                     */
+12 −0
Original line number Diff line number Diff line
@@ -65,6 +65,18 @@ typedef struct
    float yaw;       /* yaw value read from the input metadata file */
    float pitch;     /* pitch value read from the input metadata file */

#ifdef OBJ_EDITING_API
    float gain;

    float edited_azimuth;
    float edited_elevation;
    float edited_radius;

    float edited_yaw;
    float edited_pitch;
    float edited_gain;
#endif

    int16_t non_diegetic_flag; /* Non-diegetic (non-headtracked) object flag */

    ISM_METADATA_ANGLE position_angle;    /* Angle structs for azimuth and elevation */
Loading