Commit db2478ac authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Merge remote-tracking branch 'origin/main' into object-edit-run-tests

parents 13973d73 7ce3889a
Loading
Loading
Loading
Loading
Loading
+1 −76
Original line number Diff line number Diff line
@@ -129,9 +129,7 @@ typedef struct
    AcousticEnvironmentSequence aeSequence;
    bool dpidEnabled;
    uint16_t directivityPatternId[IVAS_MAX_NUM_OBJECTS];
#ifdef OBJ_EDITING_COMMANDLINE
    bool objEditEnabled;
#endif
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
    char *objEditFileName;
#endif
@@ -171,13 +169,11 @@ static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS
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, int16_t *pcmBuf );
#endif
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
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters, ObjectEditFileReader *objectEditFileReader );
#else
static void do_object_editing_fx( IVAS_EDITABLE_PARAMETERS *editableParameters );
#endif
#endif


/*------------------------------------------------------------------------------------------*
@@ -428,15 +424,9 @@ 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_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 )
@@ -917,9 +907,7 @@ static bool parseCmdlIVAS_dec(
    {
        arg->directivityPatternId[i] = 65535;
    }
#ifdef OBJ_EDITING_COMMANDLINE
    arg->objEditEnabled = false;
#endif
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
    arg->objEditFileName = NULL;
#endif
@@ -1391,7 +1379,6 @@ static bool parseCmdlIVAS_dec(

            i += tmp;
        }
#ifdef OBJ_EDITING_COMMANDLINE
        else if ( strcmp( argv_to_upper, "-OBJ_EDIT" ) == 0 )
        {
            arg->objEditEnabled = true;
@@ -1415,7 +1402,6 @@ static bool parseCmdlIVAS_dec(
            i++;
#endif
        }
#endif

        /*-----------------------------------------------------------------*
         * Option not recognized
@@ -1604,12 +1590,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
#ifndef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
    fprintf( stdout, "-obj_edit           : Enable objects editing\n" );
#else
    fprintf( stdout, "-obj_edit File      : Object editing instructions file or NULL for built-in example\n" );
#endif
#endif

    fprintf( stdout, "-level level        : Complexity level, level = (1, 2, 3), will be defined after characterisation. \n" );
@@ -2266,7 +2250,6 @@ static ivas_error decodeG192(
                    return error;
                }

#ifdef OBJ_EDITING_API
                /* Object metadata editing */
                if ( arg.objEditEnabled )
                {
@@ -2289,53 +2272,12 @@ static ivas_error decodeG192(
                    }
#endif

#ifdef OBJ_EDITING_EXAMPLE
                    /* Do object metadata editing here ... */
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
                    do_object_editing_fx( &editableParameters, objectEditFileReader );
#else
                    do_object_editing_fx( &editableParameters );
#endif
#else
                    /* edit object parameters...*/

                    /* 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;
                                editableParameters.ism_metadata[obj_idx].azimuth_fx = (Word32) ( ( start_angle + (float) non_diegetic_obj_idx * angle_inc ) * powf( 2.0f, 22.0f ) );
                                non_diegetic_obj_idx++;
                            }
                        }
                    }

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

                    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 )
@@ -2351,7 +2293,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 )
@@ -2806,9 +2747,7 @@ static ivas_error decodeVoIP(
    int16_t vec_pos_update, vec_pos_len;
    int16_t nOutSamples = 0;
    bool bitstreamReadDone = false;
#ifdef OBJ_EDITING_API
    bool parametersAvailableForEditing = false;
#endif
    uint16_t nSamplesRendered;

    vec_pos_update = 0;
@@ -3109,17 +3048,9 @@ static ivas_error decodeVoIP(
        while ( nSamplesRendered < nOutSamples )
        {
#ifdef SUPPORT_JBM_TRACEFILE
#ifdef OBJ_EDITING_API
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, &parametersAvailableForEditing, 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, &parametersAvailableForEditing, systemTime_ms ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, &bitstreamReadDone, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#endif
            {
                fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -3150,7 +3081,6 @@ static ivas_error decodeVoIP(
                }
            }

#ifdef OBJ_EDITING_API
            /* Object metadata editing */
            if ( arg.objEditEnabled && parametersAvailableForEditing == true )
            {
@@ -3164,14 +3094,12 @@ static ivas_error decodeVoIP(
                }

                /* Do object metadata editing here ... */
#ifdef OBJ_EDITING_EXAMPLE
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
                do_object_editing_fx( &editableParameters, objectEditFileReader );
#else
                do_object_editing_fx( &editableParameters );
#endif

#endif
                /* set new object parameters */
                if ( ( error = IVAS_DEC_SetEditableParameters( hIvasDec, editableParameters ) ) != IVAS_ERR_OK )
                {
@@ -3179,7 +3107,6 @@ static ivas_error decodeVoIP(
                    return error;
                }
            }
#endif
        } /* while ( nSamplesRendered < nOutSamples ) */

        /* write JBM Offset file entry */
@@ -3311,9 +3238,9 @@ static ivas_error decodeVoIP(
        {
            fprintf( stdout, "%-8d\b\b\b\b\b\b\b\b", frame );
        }
#endif
        vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len;
        frame++;
#endif
        if ( vec_pos_update == 0 )
        {
            systemTime_ms += vec_pos_len * systemTimeInc_ms;
@@ -3483,7 +3410,6 @@ cleanup:
    return error;
}

#ifdef OBJ_EDITING_EXAMPLE

/*---------------------------------------------------------------------*
 * do_object_editing_fx()
@@ -3603,7 +3529,6 @@ static void do_object_editing_fx(
    return;
}

#endif

/*---------------------------------------------------------------------*
 * load_hrtf_from_file()
+0 −4
Original line number Diff line number Diff line
@@ -141,13 +141,10 @@ typedef struct _IVAS_ISM_METADATA
    float yaw;
    float pitch;
    Word16 non_diegetic_flag;
#ifdef OBJ_EDITING_API
    Word32 gain_fx; /* Q29 */
#endif

} IVAS_ISM_METADATA;

#ifdef OBJ_EDITING_API
typedef struct _IVAS_EDITABLE_PARAMETERS
{
    Word16 num_obj;
@@ -155,7 +152,6 @@ typedef struct _IVAS_EDITABLE_PARAMETERS
    Word32 gain_bed_fx; /* Q29 */

} IVAS_EDITABLE_PARAMETERS;
#endif

typedef struct
{
+0 −2
Original line number Diff line number Diff line
@@ -1257,11 +1257,9 @@ enum
#define NBITS_HR_COH                            4
#define OMASA_TDREND_MATCHING_GAIN_FX 26026
//TODO: insert proper Q representations
#ifdef OMASA_OBJECT_EDITING
#define OMASA_GAIN_EDIT_THR_FX                  246                         /* OMASA gain change threshold, 0.06f in Q12 */
#define OMASA_AZI_EDIT_THR_FX                   ONE_IN_Q22                  /* OMASA-DISC azimuth change threshold, 1.0f in Q22 */
#define OMASA_ELE_EDIT_THR_FX                   ONE_IN_Q23                  /* OMASA-DISC elevation change threshold, 2.0f in Q22 */
#endif

#define MASA_INV_ANGLE_AT_EQUATOR_DEG_Q30       1453366656l                 /* 1.353553128183453f in Q30 */

+0 −4
Original line number Diff line number Diff line
@@ -77,9 +77,7 @@ 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
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
    IVAS_ERR_OBJECTS_EDITING_AND_PANNING_NOT_SUPPORTED,
#endif
@@ -255,10 +253,8 @@ 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
#ifdef FIX_1217_OBJECT_EDIT_FILE_INTERFACE
        case IVAS_ERR_OBJECTS_EDITING_AND_PANNING_NOT_SUPPORTED:
            return "Wrong use of both Object editing and Non-diegetic panning";
+0 −2
Original line number Diff line number Diff line
@@ -470,7 +470,6 @@ void ivas_ism_reset_metadata(
    hIsmMeta->non_diegetic_flag = 0;
    move16();

#ifdef OBJ_EDITING_API
    hIsmMeta->edited_gain_fx = ONE_IN_Q29;
    move32();
    hIsmMeta->edited_azimuth_fx = 0;
@@ -487,7 +486,6 @@ void ivas_ism_reset_metadata(
    move32();
    hIsmMeta->non_diegetic_flag = 0;
    move16();
#endif

    return;
}
Loading