Commit 0b83063d authored by Vladimir Malenovsky's avatar Vladimir Malenovsky
Browse files

Merge branch 'main' into 18-allocation-of-memory-for-the-buffers-of-bitstream-indices-7

parents 3e3a924d 559566c8
Loading
Loading
Loading
Loading
Loading
+48 −203
Original line number Diff line number Diff line
@@ -42,9 +42,7 @@
#include "ls_custom_file_reader.h"
#include "hrtf_file_reader.h"
#include "head_rotation_file_reader.h"
#ifdef OTR_REFERENCE_VECTOR_TRACKING
#include "vector3_pair_file_reader.h"
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
#include "jbm_file_writer.h"
#include "evs_rtp_payload.h"
#ifdef DEBUGGING
@@ -72,18 +70,11 @@ static
#define MAX_NUM_OUTPUT_CHANNELS    16
#define MAX_OUTPUT_PCM_BUFFER_SIZE ( MAX_NUM_OUTPUT_CHANNELS * MAX_FRAME_SIZE )

#ifdef FIX_I109_ORIENTATION_TRACKING
#define IVAS_PUBLIC_ORIENT_TRK_NONE        ( 0 )
#define IVAS_PUBLIC_ORIENT_TRK_REF         ( 1 )
#define IVAS_PUBLIC_ORIENT_TRK_AVG         ( 2 )
#ifdef OTR_REFERENCE_VECTOR_TRACKING
#define IVAS_PUBLIC_ORIENT_TRK_REF_VEC     ( 3 )
#define IVAS_PUBLIC_ORIENT_TRK_REF_VEC_LEV ( 4 )
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
#else
#define IVAS_PUBLIC_ORIENT_TRK_REF 0
#define IVAS_PUBLIC_ORIENT_TRK_AVG 1
#endif

typedef struct
{
@@ -97,14 +88,10 @@ typedef struct
    bool voipMode;
    bool enableHeadRotation;
    char *headrotTrajFileName;
#ifdef FIX_I109_ORIENTATION_TRACKING
    bool enableReferenceRotation;
    char *refrotTrajFileName;
#endif
#ifdef OTR_REFERENCE_VECTOR_TRACKING
    bool enableReferenceVectorTracking;
    char *referenceVectorTrajFileName;
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
#ifdef SUPPORT_JBM_TRACEFILE
    char *jbmTraceFilename;
#endif
@@ -140,15 +127,7 @@ typedef struct

static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
#ifdef FIX_I109_ORIENTATION_TRACKING
#ifdef OTR_REFERENCE_VECTOR_TRACKING
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, HeadRotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#else /* OTR_REFERENCE_VECTOR_TRACKING */
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, HeadRotFileReader *refRotReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
#else
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, HeadRotFileReader *headRotReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec );
#ifdef DEBUGGING
static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec );
@@ -174,12 +153,8 @@ int main(
    LsCustomFileReader *hLsCustomReader = NULL;
    hrtfFileReader *hrtfReader = NULL;
    HeadRotFileReader *headRotReader = NULL;
#ifdef FIX_I109_ORIENTATION_TRACKING
    HeadRotFileReader *refRotReader = NULL;
#endif
#ifdef OTR_REFERENCE_VECTOR_TRACKING
    Vector3PairFileReader *referenceVectorReader = NULL;
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
    ivas_error error = IVAS_ERR_UNKNOWN;
    int16_t pcmBuf[MAX_OUTPUT_PCM_BUFFER_SIZE];
    RenderConfigReader *renderConfigReader = NULL;
@@ -289,32 +264,59 @@ int main(
        }
    }

#ifdef FIX_I109_ORIENTATION_TRACKING
    /*------------------------------------------------------------------------------------------*
     * Open reference rotation file
     *------------------------------------------------------------------------------------------*/

    if ( arg.enableReferenceRotation )
    {
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nError: Reference rotation file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }

        /* sanity check */
        if ( arg.orientation_tracking != IVAS_PUBLIC_ORIENT_TRK_REF )
        {
            fprintf( stderr, "\nError: Reference rotation file can be used in '-otr ref' mode only.\n\n" );
            goto cleanup;
        }

        if ( ( error = HeadRotationFileReader_open( arg.refrotTrajFileName, &refRotReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open reference rotation file %s \n\n", arg.refrotTrajFileName );
            goto cleanup;
        }
    }
#endif
#ifdef OTR_REFERENCE_VECTOR_TRACKING

    /*------------------------------------------------------------------------------------------*
     * Open reference vector trajectory file
     *------------------------------------------------------------------------------------------*/

    if ( arg.enableReferenceVectorTracking )
    {
        /* sanity check */
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
        {
            fprintf( stderr, "\nError: Reference vector trajectory file cannot be used in this output configuration.\n\n" );
            goto cleanup;
        }

        /* sanity check */
        if ( arg.orientation_tracking != IVAS_PUBLIC_ORIENT_TRK_REF_VEC && arg.orientation_tracking != IVAS_PUBLIC_ORIENT_TRK_REF_VEC_LEV )
        {
            fprintf( stderr, "\nError: Reference trajectory file can be used in '-otr ref_vec' or '-otr ref_vec_lev' mode only.\n\n" );
            goto cleanup;
        }

        if ( ( error = Vector3PairFileReader_open( arg.referenceVectorTrajFileName, &referenceVectorReader ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError: Can't open reference vector trajectory file %s \n\n", arg.referenceVectorTrajFileName );
            goto cleanup;
        }
    }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */

    /*------------------------------------------------------------------------------------------*
     * Open custom loudspeaker layout file
@@ -459,17 +461,9 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

        /* sanity check */
#ifdef TD5
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM && arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL )
#else
        if ( arg.outputFormat != IVAS_DEC_OUTPUT_BINAURAL_ROOM )
#endif
        {
#ifdef TD5
            fprintf( stderr, "\nExternal Renderer Config is supported only for BINAURAL and BINAURAL_ROOM. Exiting. \n\n" );
#else
            fprintf( stderr, "\nExternal Renderer Config is supported only when BINAURAL_ROOM is used as output. Exiting. \n\n" );
#endif
            goto cleanup;
        }

@@ -572,15 +566,7 @@ int main(
    }
    else
    {
#ifdef FIX_I109_ORIENTATION_TRACKING
#ifdef OTR_REFERENCE_VECTOR_TRACKING
        error = decodeG192( arg, hBsReader, headRotReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf );
#else
        error = decodeG192( arg, hBsReader, headRotReader, refRotReader, hIvasDec, pcmBuf );
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
#else
        error = decodeG192( arg, hBsReader, headRotReader, hIvasDec, pcmBuf );
#endif
    }

    if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE )
@@ -636,12 +622,8 @@ cleanup:
    CustomLsReader_close( &hLsCustomReader );
    hrtfFileReader_close( &hrtfReader );
    HeadRotationFileReader_close( &headRotReader );
#ifdef FIX_I109_ORIENTATION_TRACKING
    HeadRotationFileReader_close( &refRotReader );
#endif
#ifdef OTR_REFERENCE_VECTOR_TRACKING
    Vector3PairFileReader_close( &referenceVectorReader );
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
    RenderConfigReader_close( &renderConfigReader );

    if ( BS_Reader_Close( &hBsReader ) != IVAS_ERR_OK )
@@ -778,17 +760,11 @@ static bool parseCmdlIVAS_dec(

    arg->enableHeadRotation = false;
    arg->headrotTrajFileName = NULL;
#ifdef FIX_I109_ORIENTATION_TRACKING
    arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_NONE;
    arg->enableReferenceRotation = false;
    arg->headrotTrajFileName = NULL;
#ifdef OTR_REFERENCE_VECTOR_TRACKING
    arg->enableReferenceVectorTracking = false;
    arg->referenceVectorTrajFileName = NULL;
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
#else
    arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF;
#endif

#ifdef SUPPORT_JBM_TRACEFILE
    arg->jbmTraceFilename = NULL;
@@ -928,9 +904,7 @@ static bool parseCmdlIVAS_dec(
        }
#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
        /*-----------------------------------------------------------------*
         * Define additional subfolder for debug info output in ./res
         *-----------------------------------------------------------------*/
        /* Define additional subfolder for debug info output in ./res */
        else if ( strcmp( argv_to_upper, "-INFO" ) == 0 )
        {
            extern char infoFolder[FILENAME_MAX];
@@ -963,27 +937,16 @@ static bool parseCmdlIVAS_dec(
        }
        else if ( strcmp( argv_to_upper, "-OTR" ) == 0 )
        {
#ifndef FIX_I109_ORIENTATION_TRACKING
            if ( strlen( argv[i + 1] ) > 3 )
            {
                fprintf( stderr, "Error: Invalid orientation tracking type %s \n\n", argv[i + 1] );
                usage_dec();
                return false;
            }
#endif

            strncpy( argv_to_upper, argv[i + 1], sizeof( argv_to_upper ) - 1 );
            argv_to_upper[sizeof( argv_to_upper ) - 1] = '\0';
            to_upper( argv_to_upper );

#ifdef FIX_I109_ORIENTATION_TRACKING
            if ( strcmp( argv_to_upper, "NONE" ) == 0 )
            {
                arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_NONE;
            }
            else
#endif
                if ( strcmp( argv_to_upper, "REF" ) == 0 )
            else if ( strcmp( argv_to_upper, "REF" ) == 0 )
            {
                arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF;
            }
@@ -991,7 +954,6 @@ static bool parseCmdlIVAS_dec(
            {
                arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_AVG;
            }
#ifdef OTR_REFERENCE_VECTOR_TRACKING
            else if ( strcmp( argv_to_upper, "REF_VEC" ) == 0 )
            {
                arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF_VEC;
@@ -1000,7 +962,6 @@ static bool parseCmdlIVAS_dec(
            {
                arg->orientation_tracking = IVAS_PUBLIC_ORIENT_TRK_REF_VEC_LEV;
            }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
            else
            {
                fprintf( stderr, "Error: Invalid orientation tracking type %s \n\n", argv[i + 1] );
@@ -1009,7 +970,6 @@ static bool parseCmdlIVAS_dec(
            }
            i += 2;
        }
#ifdef FIX_I109_ORIENTATION_TRACKING
        else if ( strcmp( argv_to_upper, "-RF" ) == 0 )
        {
            arg->enableReferenceRotation = true;
@@ -1025,8 +985,6 @@ static bool parseCmdlIVAS_dec(
            arg->refrotTrajFileName = argv[i];
            i++;
        }
#endif
#ifdef OTR_REFERENCE_VECTOR_TRACKING
        else if ( strcmp( argv_to_upper, "-RVF" ) == 0 )
        {
            arg->enableReferenceVectorTracking = true;
@@ -1042,7 +1000,6 @@ static bool parseCmdlIVAS_dec(
            arg->referenceVectorTrajFileName = argv[i];
            i++;
        }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
        else if ( strcmp( argv_to_upper, "-RENDER_CONFIG" ) == 0 )
        {
            arg->renderConfigEnabled = true;
@@ -1225,8 +1182,19 @@ static void usage_dec( void )
    fprintf( stdout, "                      Format files, the magic word in the mime file is used to determine\n" );
    fprintf( stdout, "                      which of the two supported formats is in use.\n" );
    fprintf( stdout, "                      default bitstream file format is G.192\n" );
    fprintf( stdout, "-T File             : Head rotation specified by external trajectory File\n" );
    fprintf( stdout, "-hrtf File          : HRTF filter File used in BINAURAL output configuration\n" );
    fprintf( stdout, "-T File             : Head rotation specified by external trajectory File\n" );
    fprintf( stdout, "-otr tracking_type  : Head orientation tracking type: 'none', 'ref', 'avg', 'ref_vec' \n" );
    fprintf( stdout, "                      or 'ref_vec_lev' (only for binaural rendering)\n" );
    fprintf( stdout, "-rf File            : Reference rotation specified by external trajectory file\n" );
    fprintf( stdout, "                      works only in combination with '-otr ref' mode \n" );
    fprintf( stdout, "-rvf File           : Reference vector specified by external trajectory file\n" );
    fprintf( stdout, "                      works only in combination with '-otr ref_vec' and 'ref_vec_lev' modes\n" );
    fprintf( stdout, "-render_config File : Renderer configuration File\n" );
    fprintf( stdout, "-no_diegetic_pan    : panning mono non-diegetic sound to stereo -1<= pan <=1,\n" );
    fprintf( stdout, "                      left or l or 1->left, right or r or -1->right, center or c or  0->middle\n" );
    fprintf( stdout, "-q                  : Quiet mode, no frame counter\n" );
    fprintf( stdout, "                      default is deactivated\n" );
#ifdef DEBUGGING
    fprintf( stdout, "-FEC X              : Insert frame erasures, X = 0-10 is the percentage\n" );
    fprintf( stdout, "                      of erased frames, or X may be the name of binary file or \n" );
@@ -1235,22 +1203,6 @@ static void usage_dec( void )
    fprintf( stdout, "                      default is OFF, if this option is not used\n" );
    fprintf( stdout, "-force R            : Force specific binaural rendering mode, R = (TDREND, CLDFBREND),\n" );
#endif
#ifdef FIX_I109_ORIENTATION_TRACKING
    fprintf( stdout, "-otr tracking_type  : head orientation tracking type: 'none', 'ref' or 'avg'  (only for binaural rendering)\n" );
    fprintf( stdout, "-rf File            : Reference rotation specified by external trajectory file\n" );
    fprintf( stdout, "                      works only in combination with -otr ref mode\n" );
#else
    fprintf( stdout, "-otr tracking_type  : head orientation tracking type: 'ref' or 'avg'  (only for binaural rendering)\n" );
#endif
#ifdef OTR_REFERENCE_VECTOR_TRACKING
    fprintf( stdout, "-rvf File           : Reference vector specified by external trajectory file\n" );
    fprintf( stdout, "                      works only in combination with -otr ref_vec and ref_vec_lev modes\n" );
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
    fprintf( stdout, "-render_config file : Renderer configuration file\n" );
    fprintf( stdout, "-no_diegetic_pan    : panning mono no dietic sound to stereo -1<= pan <=1,\n" );
    fprintf( stdout, "                      left or l or 1->left, right or r or -1->right, center or c or  0->middle\n" );
    fprintf( stdout, "-q                  : Quiet mode, no frame counter\n" );
    fprintf( stdout, "                      default is deactivated\n" );
#ifdef DEBUG_MODE_INFO
#ifdef DEBUG_MODE_INFO_TWEAK
    fprintf( stdout, "-info <folder>      : specify subfolder name for debug output\n" );
@@ -1295,7 +1247,6 @@ static ivas_error initOnFirstGoodFrame(
    ivas_error error = IVAS_ERR_UNKNOWN;

    /* Now delay, number of output channels and frame size are known */
#ifdef FIX_371_DELAY_REPORT
    if ( ( error = IVAS_DEC_GetDelay( hIvasDec, pFullDelayNumSamples, delayTimeScale ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
@@ -1304,35 +1255,9 @@ static ivas_error initOnFirstGoodFrame(

    if ( !arg.delayCompensationEnabled )
    {
#ifdef BINAURALIZATION_DELAY_REPORT
        pFullDelayNumSamples[0] = 0;
#else
        *pFullDelayNumSamples = 0;
#endif
    }
#else
    if ( arg.delayCompensationEnabled )
    {
        if ( ( error = IVAS_DEC_GetDelay( hIvasDec, pFullDelayNumSamples, delayTimeScale ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nUnable to get delay of decoder: %s\n", ivas_error_to_string( error ) );
            return error;
        }
    }
    else
    {
#ifdef BINAURALIZATION_DELAY_REPORT
        pFullDelayNumSamples[0] = 0;
#else
        *pFullDelayNumSamples = 0;
#endif
    }
#endif
#ifdef BINAURALIZATION_DELAY_REPORT
    *pRemainingDelayNumSamples = pFullDelayNumSamples[0];
#else
    *pRemainingDelayNumSamples = *pFullDelayNumSamples;
#endif

    if ( ( error = IVAS_DEC_GetNumOutputChannels( hIvasDec, pNumOutChannels ) ) != IVAS_ERR_OK )
    {
@@ -1479,12 +1404,8 @@ static ivas_error decodeG192(
    DecArguments arg,
    BS_READER_HANDLE hBsReader,
    HeadRotFileReader *headRotReader,
#ifdef FIX_I109_ORIENTATION_TRACKING
    HeadRotFileReader *refRotReader,
#ifdef OTR_REFERENCE_VECTOR_TRACKING
    Vector3PairFileReader *referenceVectorReader,
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
#endif
    IVAS_DEC_HANDLE hIvasDec,
    int16_t *pcmBuf )

@@ -1502,19 +1423,13 @@ static ivas_error decodeG192(
    int16_t numInitialBadFrames = 0; /* Number of bad frames received until first good frame is decoded */
    int16_t nOutChannels = 0;
    int16_t delayNumSamples = -1;
#ifdef BINAURALIZATION_DELAY_REPORT
    int16_t delayNumSamples_orig[3]; /* stores: overall delay, dec+rend delay, and binauralization delay */
#else
    int16_t delayNumSamples_orig = 0;
#endif
    int16_t nOutSamples = 0;
    int32_t delayTimeScale = 0;
    ivas_error error = IVAS_ERR_UNKNOWN;
    uint16_t numObj = 0;
    IVAS_DEC_BS_FORMAT bsFormat = IVAS_DEC_BS_UNKOWN;
#ifdef TD5
    IVAS_POSITION Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];
#endif

    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
@@ -1532,9 +1447,7 @@ static ivas_error decodeG192(
        fprintf( stdout, "\n-- Start the decoder (quiet mode) --\n\n" );
    }

#ifdef BINAURALIZATION_DELAY_REPORT
    delayNumSamples_orig[0] = -1;
#endif

#ifdef WMOPS
    reset_stack();
@@ -1584,8 +1497,6 @@ static ivas_error decodeG192(
            goto cleanup;
        }

#ifdef FIX_I109_ORIENTATION_TRACKING
#ifdef OTR_REFERENCE_VECTOR_TRACKING
        /* reference vector */
        if ( arg.enableReferenceVectorTracking )
        {
@@ -1602,16 +1513,11 @@ static ivas_error decodeG192(
                goto cleanup;
            }
        }
#endif /* OTR_REFERENCE_VECTOR_TRACKING */
        /* Reference rotation */
        if ( arg.enableReferenceRotation )
        {
            IVAS_QUATERNION quaternion;
#ifdef TD5
            if ( ( error = HeadRotationFileReading( refRotReader, &quaternion, NULL ) ) != IVAS_ERR_OK )
#else
            if ( ( error = HeadRotationFileReading( refRotReader, &quaternion ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError %s while reading reference rotation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( refRotReader ) );
                goto cleanup;
@@ -1623,42 +1529,21 @@ static ivas_error decodeG192(
                goto cleanup;
            }
        }
#endif
        /* Head-tracking input simulation */
        if ( arg.enableHeadRotation )
        {
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

#ifdef FIX_I109_ORIENTATION_TRACKING
            for ( i = 0; i < IVAS_MAX_PARAM_SPATIAL_SUBFRAMES; i++ )
            {
#ifdef TD5
                if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
#else
                if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i] ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                    goto cleanup;
                }
            }
#else
#ifdef TD5
            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, Pos ) ) != IVAS_ERR_OK )
#else
            if ( ( error = HeadRotationFileReading( headRotReader, Quaternions, frame ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nError %s while reading head orientation from %s\n", IVAS_DEC_GetErrorMessage( error ), HeadRotationFileReader_getFilePath( headRotReader ) );
                goto cleanup;
            }
#endif

#ifdef TD5
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions, Pos ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
@@ -1688,11 +1573,7 @@ static ivas_error decodeG192(
                    arg,
                    numInitialBadFrames,
                    nOutSamples,
#ifdef BINAURALIZATION_DELAY_REPORT
                    delayNumSamples_orig,
#else
                    &delayNumSamples_orig,
#endif
                    &delayNumSamples,
                    &delayTimeScale,
                    &bsFormat,
@@ -1806,13 +1687,8 @@ static ivas_error decodeG192(
     * Add zeros at the end to have equal length of synthesized signals
     *------------------------------------------------------------------------------------------*/

#ifdef BINAURALIZATION_DELAY_REPORT
    memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK )
#else
    memset( pcmBuf, 0, delayNumSamples_orig * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig * nOutChannels ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
@@ -1824,21 +1700,13 @@ static ivas_error decodeG192(

    if ( !arg.quietModeEnabled )
    {
#ifdef BINAURALIZATION_DELAY_REPORT
        printf( "\n\nDecoder+renderer delay: %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[1] / (float) delayTimeScale, delayNumSamples_orig[1], delayTimeScale );

        if ( delayNumSamples_orig[2] > 0 )
        {
            printf( "HRIR/BRIR delay:        %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[2] / (float) delayTimeScale, delayNumSamples_orig[2], delayTimeScale );
#ifdef FIX_371_DELAY_REPORT
            printf( "Total delay:            %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * ( delayNumSamples_orig[1] + delayNumSamples_orig[2] ) / (float) delayTimeScale, delayNumSamples_orig[1] + delayNumSamples_orig[2], delayTimeScale );
#else
            printf( "Total delay:            %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[0] / (float) delayTimeScale, delayNumSamples_orig[0], delayTimeScale );
#endif
        }
#else
        fprintf( stdout, "\nDecoder delay:          %-5u [samples]  - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale );
#endif
    }

    /* Print output metadata file name(s) */
@@ -2027,11 +1895,7 @@ static ivas_error decodeVoIP(
#endif
    JbmOffsetFileWriter *jbmOffsetWriter = NULL;

#ifdef BINAURALIZATION_DELAY_REPORT
    int16_t delayNumSamples_orig[3]; /* stores: overall delay, dec+rend delay, and binauralization delay */
#else
    int16_t delayNumSamples_orig = -1;
#endif
    int16_t delayNumSamples = -1;
    int32_t delayTimeScale = -1;

@@ -2051,9 +1915,7 @@ static ivas_error decodeVoIP(
        ismWriters[i] = NULL;
    }

#ifdef BINAURALIZATION_DELAY_REPORT
    delayNumSamples_orig[0] = -1;
#endif

    rtpdumpDepacker.rtpdump = NULL;
    switch ( arg.inputFormat )
@@ -2250,11 +2112,7 @@ static ivas_error decodeVoIP(
                    arg,
                    numInitialBadFrames,
                    nOutSamples,
#ifdef BINAURALIZATION_DELAY_REPORT
                    delayNumSamples_orig,
#else
                    &delayNumSamples_orig,
#endif
                    &delayNumSamples,
                    &delayTimeScale,
                    &bsFormat,
@@ -2311,13 +2169,8 @@ static ivas_error decodeVoIP(
     * Add zeros at the end to have equal length of synthesized signals
     *------------------------------------------------------------------------------------------*/

#ifdef BINAURALIZATION_DELAY_REPORT
    memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK )
#else
    memset( pcmBuf, 0, delayNumSamples_orig * nOutChannels * sizeof( int16_t ) );
    if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig * nOutChannels ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
        goto cleanup;
@@ -2329,21 +2182,13 @@ static ivas_error decodeVoIP(

    if ( !arg.quietModeEnabled )
    {
#ifdef BINAURALIZATION_DELAY_REPORT
        printf( "\n\nDecoder+renderer delay: %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[1] / (float) delayTimeScale, delayNumSamples_orig[1], delayTimeScale );

        if ( delayNumSamples_orig[2] > 0 )
        {
            printf( "HRIR/BRIR delay:        %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[2] / (float) delayTimeScale, delayNumSamples_orig[2], delayTimeScale );
#ifdef FIX_371_DELAY_REPORT
            printf( "Total delay:            %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * ( delayNumSamples_orig[1] + delayNumSamples_orig[2] ) / (float) delayTimeScale, delayNumSamples_orig[1] + delayNumSamples_orig[2], delayTimeScale );
#else
            printf( "Total delay:            %4.2f ms   (%3u samples at timescale %5u)\n", 1000.f * delayNumSamples_orig[0] / (float) delayTimeScale, delayNumSamples_orig[0], delayTimeScale );
#endif
        }
#else
        printf( "\nDecoder delay:       %5u [samples]  - Timescale: %5u\n", delayNumSamples_orig, delayTimeScale );
#endif
    }

    /*------------------------------------------------------------------------------------------*
+0 −15

File changed.

Preview size limit exceeded, changes collapsed.

+9 −138

File changed.

Preview size limit exceeded, changes collapsed.

+0 −10
Original line number Diff line number Diff line
@@ -78,10 +78,8 @@ typedef struct _IVAS_ISM_METADATA
    float radius;
    float spread;
    float gainFactor;
#ifdef TD5
    float yaw;
    float pitch;
#endif
} IVAS_ISM_METADATA;

typedef struct
@@ -90,20 +88,16 @@ typedef struct

} IVAS_QUATERNION;

#ifdef OTR_REFERENCE_VECTOR_TRACKING
typedef struct
{
    float x, y, z;
} IVAS_VECTOR3;
#endif /* OTR_REFERENCE_VECTOR_TRACKING */

#ifdef TD5
typedef struct
{
    float x, y, z;

} IVAS_POSITION;
#endif

typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE;
#ifdef FIX_350_MASA_DELAY_COMP
@@ -130,11 +124,9 @@ typedef struct
{
    float azimuth;
    float elevation;
#ifdef TD5
    float radius;
    float yaw;
    float pitch;
#endif
} IVAS_REND_AudioObjectPosition;

typedef struct _IVAS_ROOM_ACOUSTICS_CONFIG
@@ -156,9 +148,7 @@ typedef struct _IVAS_RENDER_CONFIG
    IVAS_RENDER_TYPE_OVERRIDE renderer_type_override;
#endif
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA room_acoustics;
#ifdef TD5
    float directivity[3];
#endif
} IVAS_RENDER_CONFIG_DATA, *IVAS_RENDER_CONFIG_HANDLE;

typedef struct _IVAS_LS_CUSTOM_LAYOUT
+0 −8
Original line number Diff line number Diff line
@@ -55,10 +55,6 @@ int32_t get_delay(
    const int32_t io_fs,            /* i  : input/output sampling frequency     */
    const IVAS_FORMAT ivas_format,  /* i  : IVAS format                         */
    HANDLE_CLDFB_FILTER_BANK hCldfb /* i  : Handle of Cldfb analysis            */
#ifndef BINAURALIZATION_DELAY_REPORT
    ,
    const int32_t binaural_latency_ns /* i  : binaural renderer HRTF delay in ns  */
#endif
)
{
    int32_t delay = 0;
@@ -110,10 +106,6 @@ int32_t get_delay(
                delay += IVAS_FB_DEC_DELAY_NS;
            }

#ifndef BINAURALIZATION_DELAY_REPORT
            /* compensate for binauralization delay */
            delay += binaural_latency_ns;
#endif

#ifdef FIX_350_MASA_DELAY_COMP
            if ( ivas_format == MASA_FORMAT )
Loading