Commit 9dd31f09 authored by multrus's avatar multrus
Browse files

[cleanup] accept SPLIT_REND_WITH_HEAD_ROT

parent 7cc835b4
Loading
Loading
Loading
Loading
+0 −150
Original line number Diff line number Diff line
@@ -44,9 +44,7 @@
#include "render_config_reader.h"
#include "rotation_file_reader.h"
#include "aeid_file_reader.h"
#ifdef SPLIT_REND_WITH_HEAD_ROT
#include "split_render_file_read_write.h"
#endif
#ifdef VARIABLE_SPEED_DECODING
#include "tsm_scale_file_reader.h"
#include <math.h>
@@ -134,9 +132,7 @@ typedef struct
    float non_diegetic_pan_gain;
    bool renderConfigEnabled;
    char *renderConfigFilename;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    char *outputMdFilename;
#endif
    IVAS_DEC_COMPLEXITY_LEVEL complexityLevel;
    bool tsmEnabled;
    IVAS_RENDER_FRAMESIZE renderFramesize;
@@ -164,11 +160,7 @@ typedef struct

static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
#ifdef SPLIT_REND_WITH_HEAD_ROT
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#else
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
#endif
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec );

#ifdef DEBUGGING
@@ -190,10 +182,8 @@ int main(
    bool mainFailed = true; /* Assume main failed until cleanup is reached without errors */
    DecArguments arg;
    ivas_error error = IVAS_ERR_UNKNOWN;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ISAR_SPLIT_REND_BITS_DATA splitRendBits;
    uint8_t splitRendBitsBuf[ISAR_MAX_SPLIT_REND_BITS_BUFFER_SIZE_IN_BYTES];
#endif

    /* Any handles that require cleanup must be declared here and initialized to NULL */
    IVAS_DEC_HANDLE hIvasDec = NULL;
@@ -226,9 +216,7 @@ int main(
    reset_mem( USE_BYTES );
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
    splitRendBits.bits_buf = splitRendBitsBuf;
#endif

    /*------------------------------------------------------------------------------------------*
     * Parse command-line arguments
@@ -276,7 +264,6 @@ int main(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
    {
        fprintf( stdout, "Output metadata file:   %s\n", arg.outputWavFilename );
@@ -287,7 +274,6 @@ int main(
        fprintf( stdout, "Output metadata file:   %s\n", arg.outputMdFilename );
    }
    else
#endif
    {
        fprintf( stdout, "Output synthesis file:  %s\n", arg.outputWavFilename );
    }
@@ -322,9 +308,7 @@ int main(
    {
        /* sanity check */
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
             && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM
#endif
        )
        {
            fprintf( stderr, "\nError: Head-rotation file file cannot be used in this output configuration.\n\n" );
@@ -426,10 +410,8 @@ int main(
    {
        /* sanity check */
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB
#ifdef SPLIT_REND_WITH_HEAD_ROT
             && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM &&
             arg.Opt_non_diegetic_pan == 0
#endif
        )
        {
            fprintf( stderr, "\nError: Renderer configuration file cannot be used in this output configuration.\n\n" );
@@ -466,7 +448,6 @@ int main(
        fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for decoding to EXT!\n" );
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    /*------------------------------------------------------------------------------------------*
     * Configure Split rendering
     *------------------------------------------------------------------------------------------*/
@@ -488,7 +469,6 @@ int main(

        arg.enableHeadRotation = true;
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Configure VoIP mode
@@ -617,7 +597,6 @@ int main(
        IVAS_RENDER_CONFIG_DATA renderConfig;

        /* sanity check */
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB &&
             arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM &&
             arg.Opt_non_diegetic_pan == 0 )
@@ -625,13 +604,6 @@ int main(
            fprintf( stderr, "\nExternal Renderer Config is supported only when binaural output configurations is used as output OR when Split rendering mode is enabled. Exiting. \n" );
            goto cleanup;
        }
#else
        if ( arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR && arg.outputConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
            fprintf( stderr, "\nExternal Renderer Config is supported only for binaural output configurations. Exiting. \n\n" );
            goto cleanup;
        }
#endif

        if ( ( error = IVAS_DEC_GetRenderConfig( hIvasDec, &renderConfig ) ) != IVAS_ERR_OK )
        {
@@ -655,7 +627,6 @@ int main(
            fprintf( stderr, "Failed to get Distance Attenuation \n\n" );
            goto cleanup;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
        {
            if ( asked_frame_size != IVAS_RENDER_FRAMESIZE_20MS &&
@@ -679,7 +650,6 @@ int main(
                fprintf( stderr, "\nChanged render framesize, only 20ms are allowed for non-0dof split rendering!\n" );
            }
        }
#endif

        if ( arg.outputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
        {
@@ -699,11 +669,9 @@ int main(
            renderConfig.roomAcoustics.override = true;
        }

#ifdef SPLIT_REND_WITH_HEAD_ROT
        /* ISAR frame size is set from command line, not renderer config file.
         * This will be ignored if output format is not split rendering. */
        renderConfig.split_rend_config.isar_frame_size_ms = (int16_t) arg.renderFramesize /* given in number of 5ms subframes */ * 5;
#endif

        if ( ( error = IVAS_DEC_FeedRenderConfig( hIvasDec, renderConfig ) ) != IVAS_ERR_OK )
        {
@@ -861,11 +829,7 @@ int main(
    }
    else
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT
        error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf );
#else
        error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec, pcmBuf );
#endif
    }

    if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE )
@@ -1025,7 +989,6 @@ static IVAS_AUDIO_CONFIG cmdline2config(
    {
        output_config = IVAS_AUDIO_CONFIG_BINAURAL;
    }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    else if ( strcmp( argv_to_upper, "BINAURAL_SPLIT_CODED" ) == 0 )
    {
        output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED;
@@ -1034,7 +997,6 @@ static IVAS_AUDIO_CONFIG cmdline2config(
    {
        output_config = IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM;
    }
#endif
    else if ( strcmp( argv_to_upper, "BINAURAL_ROOM_IR" ) == 0 )
    {
        output_config = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR;
@@ -1110,9 +1072,7 @@ static bool parseCmdlIVAS_dec(
    arg->renderConfigFilename = NULL;
    arg->Opt_dpid_on = 0;

#ifdef SPLIT_REND_WITH_HEAD_ROT
    arg->outputMdFilename = NULL;
#endif

    arg->inputFormat = IVAS_DEC_INPUT_FORMAT_G192;
    arg->Opt_non_diegetic_pan = 0;
@@ -1440,7 +1400,6 @@ static bool parseCmdlIVAS_dec(
            }
            i += 2;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        else if ( strcmp( argv_to_upper, "-OM" ) == 0 )
        {
            arg->outputMdFilename = argv[i + 1];
@@ -1452,7 +1411,6 @@ static bool parseCmdlIVAS_dec(
            }
            i += 2;
        }
#endif
        else if ( strcmp( argv_to_upper, "-NON_DIEGETIC_PAN" ) == 0 )
        {
            i++;
@@ -1722,13 +1680,8 @@ static void usage_dec( void )

    fprintf( stdout, "Mandatory parameters:\n" );
    fprintf( stdout, "---------------------\n" );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    fprintf( stdout, "OutputConf           : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" );
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, BINAURAL_SPLIT_CODED, BINAURAL_SPLIT_PCM, EXT\n" );
#else
    fprintf( stdout, "OutputConf           : Output configuration: MONO, STEREO, 5_1, 7_1, 5_1_2, 5_1_4, 7_1_4, FOA,\n" );
    fprintf( stdout, "                       HOA2, HOA3, BINAURAL, BINAURAL_ROOM_IR, BINAURAL_ROOM_REVERB, EXT\n" );
#endif
    fprintf( stdout, "                       By default, channel order and loudspeaker positions are equal to the\n" );
    fprintf( stdout, "                       encoder. For loudspeaker outputs, OutputConf can be a custom loudspeaker\n" );
    fprintf( stdout, "                       layout file. See readme.txt for details.\n" );
@@ -1774,9 +1727,7 @@ static void usage_dec( void )
    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" );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    fprintf( stdout, "-om File            : Metadata output File for BINAURAL_SPLIT_PCM OutputConf (only for Fs = 48 kHz)\n" );
#endif
    fprintf( stdout, "-non_diegetic_pan P : panning mono non-diegetic sound to stereo with paning P, -90<= P <=90,\n" );
    fprintf( stdout, "                      left or l or 90->left, right or r or -90->right, center or c or  0->middle\n" );
#ifdef DEBUGGING
@@ -1836,12 +1787,8 @@ static ivas_error initOnFirstGoodFrame(
    IVAS_DEC_HANDLE hIvasDec,          /* i/o: */
    const DecArguments arg,            /* i  : */
    const int16_t numInitialBadFrames, /* i  : */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t *numOutSamples, /* i/o: */
    int16_t *vec_pos_len,   /* i/o: */
#else
    const uint16_t numOutSamples, /* i  : */
#endif
    int16_t *pFullDelayNumSamples,                   /* o  : */
    int16_t *pRemainingDelayNumSamples,              /* o  : */
    int32_t *delayTimeScale,                         /* o  : */
@@ -1850,17 +1797,11 @@ static ivas_error initOnFirstGoodFrame(
    MasaFileWriter **ppMasaWriter,                   /* o  : */
    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS], /* o  : */
    int16_t *pNumOutChannels,                        /* o  : */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    uint16_t *pNumObj, /* o  : */
    SplitFileReadWrite **splitRendWriter
#else
    uint16_t *pNumObj             /* o  : */
#endif
)
{
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t isSplitRend, isSplitCoded;
#endif
    ivas_error error = IVAS_ERR_UNKNOWN;

    /* Now delay, number of output channels and frame size are known */
@@ -1870,7 +1811,6 @@ static ivas_error initOnFirstGoodFrame(
        return error;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( ( error = IVAS_DEC_is_split_rendering_enabled( hIvasDec, &isSplitRend ) ) != IVAS_ERR_OK )
    {
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_enabled, code: %d\n", error );
@@ -1887,7 +1827,6 @@ static ivas_error initOnFirstGoodFrame(
    {
        pFullDelayNumSamples[0] = 0;
    }
#endif

    if ( !arg.delayCompensationEnabled )
    {
@@ -1909,7 +1848,6 @@ static ivas_error initOnFirstGoodFrame(
        return error;
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( isSplitRend )
    {
        /* Open split rendering metadata writer */
@@ -1959,23 +1897,19 @@ static ivas_error initOnFirstGoodFrame(

    if ( !isSplitCoded )
    {
#endif
        /* Open audio writer and write all previously skipped bad frames now that frame size is known */
        if ( ( error = AudioFileWriter_open( ppAfWriter, arg.outputWavFilename, arg.output_Fs, *pNumOutChannels ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nUnable to open output file %s\n", arg.outputWavFilename );
            return error;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif

    int16_t *zeroBuf = malloc( pcmFrameSize * sizeof( int16_t ) );
    memset( zeroBuf, 0, pcmFrameSize * sizeof( int16_t ) );

    for ( int16_t i = 0; i < numInitialBadFrames; ++i )
    {
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( *splitRendWriter != NULL )
        {
            ISAR_SPLIT_REND_BITS_DATA splitRendBitsZero;
@@ -1996,19 +1930,10 @@ static ivas_error initOnFirstGoodFrame(
        }
        else
        {
#endif

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( *pRemainingDelayNumSamples < *numOutSamples )
#else
        if ( *pRemainingDelayNumSamples < numOutSamples )
#endif
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, *numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK )
#else
            if ( ( error = AudioFileWriter_write( *ppAfWriter, zeroBuf, numOutSamples * *pNumOutChannels - ( *pRemainingDelayNumSamples * *pNumOutChannels ) ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nOutput audio file writer error\n" );
                    return error;
@@ -2017,15 +1942,9 @@ static ivas_error initOnFirstGoodFrame(
            }
            else
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                *pRemainingDelayNumSamples -= *numOutSamples;
#else
            *pRemainingDelayNumSamples -= numOutSamples;
#endif
            }
#ifdef SPLIT_REND_WITH_HEAD_ROT
        }
#endif
    }

    free( zeroBuf );
@@ -2112,7 +2031,6 @@ static ivas_error initOnFirstGoodFrame(
        }
    }

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( *splitRendWriter != NULL )
    {
        if ( numOutSamples == NULL || vec_pos_len == NULL )
@@ -2132,7 +2050,6 @@ static ivas_error initOnFirstGoodFrame(
            return error;
        }
    }
#endif

    return IVAS_ERR_OK;
}
@@ -2151,9 +2068,7 @@ static ivas_error decodeG192(
    RotFileReader *externalOrientationFileReader,
    RotFileReader *refRotReader,
    Vector3PairFileReader *referenceVectorReader,
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ISAR_SPLIT_REND_BITS_DATA *splitRendBits,
#endif
    IVAS_DEC_HANDLE hIvasDec,
    int16_t *pcmBuf )

@@ -2189,7 +2104,6 @@ static ivas_error decodeG192(
    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
    int16_t vec_pos_update, vec_pos_len;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    SplitFileReadWrite *splitRendWriter = NULL;
    int16_t isSplitRend, isSplitCoded;

@@ -2204,7 +2118,6 @@ static ivas_error decodeG192(
        fprintf( stderr, "\nError in IVAS_DEC_is_split_rendering_coded_out, code: %d\n", error );
        return error;
    }
#endif

    IVAS_RENDER_CONFIG_DATA renderConfig;
    RenderConfigReader *renderConfigReader = NULL;
@@ -2363,7 +2276,6 @@ static ivas_error decodeG192(
        {
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( headRotReader == NULL )
            {
                for ( i = 0; i < num_subframes; i++ )
@@ -2379,7 +2291,6 @@ static ivas_error decodeG192(
            }
            else
            {
#endif
                for ( i = 0; i < num_subframes; i++ )
                {
                    if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
@@ -2388,17 +2299,11 @@ static ivas_error decodeG192(
                        goto cleanup;
                    }
                }
#ifdef SPLIT_REND_WITH_HEAD_ROT
            }
#endif

            for ( i = 0; i < num_subframes; i++ )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
@@ -2522,7 +2427,6 @@ static ivas_error decodeG192(
                }
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( isSplitRend )
            {
                if ( ( error = IVAS_DEC_GetSplitBinauralBitstream( hIvasDec, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), splitRendBits, &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
@@ -2536,21 +2440,14 @@ static ivas_error decodeG192(
            }
            else
            {
#endif
#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, IVAS_DEC_PCM_INT16, (void *) ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )
#else
            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 ) );
                    goto cleanup;
                }
                nSamplesRendered += nSamplesRendered_loop;
                nSamplesToRender -= nSamplesRendered_loop;
#ifdef SPLIT_REND_WITH_HEAD_ROT
            }
#endif
            if ( needNewFrame )
            {
                frame++;
@@ -2584,11 +2481,7 @@ static ivas_error decodeG192(
            /* Once good frame decoded, catch up */
            if ( decodedGoodFrame )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, &vec_pos_len, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK )
#else
                if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale, &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK )
#endif
                {
                    goto cleanup;
                }
@@ -2602,7 +2495,6 @@ static ivas_error decodeG192(
        /* Write current frame */
        if ( decodedGoodFrame )
        {
#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( isSplitRend )
            {
                if ( split_rend_write_bitstream_to_file( splitRendWriter, splitRendBits->bits_buf, &splitRendBits->bits_read, &splitRendBits->bits_written ) != IVAS_ERR_OK )
@@ -2614,7 +2506,6 @@ static ivas_error decodeG192(

            if ( !isSplitCoded )
            {
#endif
                if ( delayNumSamples < nOutSamples )
                {
                    if ( ( error = AudioFileWriter_write( afWriter, &pcmBuf[delayNumSamples * nOutChannels], nOutSamples * nOutChannels - ( delayNumSamples * nOutChannels ) ) ) != IVAS_ERR_OK )
@@ -2628,9 +2519,7 @@ static ivas_error decodeG192(
                {
                    delayNumSamples -= nOutSamples;
                }
#ifdef SPLIT_REND_WITH_HEAD_ROT
            }
#endif
        }

        /* Write ISm metadata to external file(s) */
@@ -2751,11 +2640,7 @@ static ivas_error decodeG192(
                goto cleanup;
            }

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0, DEFAULT_AXIS ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternion, Pos[0], 0 ) ) != IVAS_ERR_OK )
#endif
            {
                fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
@@ -2763,11 +2648,7 @@ static ivas_error decodeG192(
        }

        /* decode and get samples */
#ifdef SPLIT_REND_WITH_HEAD_ROT
        if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
#else
        if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
#endif
        {
            fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
@@ -2886,18 +2767,14 @@ static ivas_error decodeG192(

    memset( pcmBuf, 0, delayNumSamples_orig[0] * nOutChannels * sizeof( int16_t ) );

#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( afWriter != NULL )
    {
#endif
        if ( ( error = AudioFileWriter_write( afWriter, pcmBuf, delayNumSamples_orig[0] * nOutChannels ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nError writing output file: %s\n", ivas_error_to_string( error ) );
            goto cleanup;
        }
#ifdef SPLIT_REND_WITH_HEAD_ROT
    }
#endif

    /*------------------------------------------------------------------------------------------*
     * Close files and deallocate resources
@@ -2908,9 +2785,7 @@ static ivas_error decodeG192(
cleanup:

    RenderConfigReader_close( &renderConfigReader );
#ifdef SPLIT_REND_WITH_HEAD_ROT
    split_rend_reader_writer_close( &splitRendWriter );
#endif
    AudioFileWriter_close( &afWriter );
    MasaFileWriter_close( &masaWriter );
#ifdef DEBUGGING
@@ -3262,7 +3137,6 @@ static ivas_error decodeVoIP(
        {
            IVAS_QUATERNION Quaternions[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES];

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( headRotReader == NULL )
            {
                for ( i = 0; i < num_subframes; i++ )
@@ -3278,7 +3152,6 @@ static ivas_error decodeVoIP(
            }
            else
            {
#endif
                for ( i = 0; i < num_subframes; i++ )
                {
                    if ( ( error = HeadRotationFileReading( headRotReader, &Quaternions[i], &Pos[i] ) ) != IVAS_ERR_OK )
@@ -3288,17 +3161,11 @@ static ivas_error decodeVoIP(
                        goto cleanup;
                    }
                }
#ifdef SPLIT_REND_WITH_HEAD_ROT
            }
#endif

            for ( i = 0; i < num_subframes; i++ )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i, DEFAULT_AXIS ) ) != IVAS_ERR_OK )
#else
                if ( ( error = IVAS_DEC_FeedHeadTrackData( hIvasDec, Quaternions[i], Pos[i], i ) ) != IVAS_ERR_OK )
#endif
                {
                    fprintf( stderr, "\nIVAS_DEC_FeedHeadTrackData failed: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
@@ -3385,18 +3252,10 @@ static ivas_error decodeVoIP(


        /* decode and get samples */
#ifdef SPLIT_REND_WITH_HEAD_ROT
#ifdef SUPPORT_JBM_TRACEFILE
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
#else
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef SUPPORT_JBM_TRACEFILE
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
#else
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#endif
        {
            fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -3433,15 +3292,10 @@ static ivas_error decodeVoIP(
            /* Once good frame decoded, catch up */
            if ( decodedGoodFrame )
            {
#ifdef SPLIT_REND_WITH_HEAD_ROT
                SplitFileReadWrite *splitRendWriter = NULL;

                if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, &nOutSamples, NULL, delayNumSamples_orig, &delayNumSamples, &delayTimeScale,
                                                     &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj, &splitRendWriter ) ) != IVAS_ERR_OK )
#else
                if ( ( error = initOnFirstGoodFrame( hIvasDec, arg, numInitialBadFrames, nOutSamples, delayNumSamples_orig, &delayNumSamples, &delayTimeScale,
                                                     &bsFormat, &afWriter, &masaWriter, ismWriters, &nOutChannels, &numObj ) ) != IVAS_ERR_OK )
#endif
                {
                    goto cleanup;
                }
@@ -3546,11 +3400,7 @@ static ivas_error decodeVoIP(
    int16_t nSamplesFlushed = 0;

    /* decode and get samples */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, IVAS_DEC_PCM_INT16, (void *) pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
#else
    if ( ( error = IVAS_DEC_Flush( hIvasDec, nOutSamples, pcmBuf, &nSamplesFlushed ) ) != IVAS_ERR_OK )
#endif
    {
        fprintf( stderr, "\nError in IVAS_DEC_VoIP_Flush: %s\n", IVAS_DEC_GetErrorMessage( error ) );
        goto cleanup;
+0 −12
Original line number Diff line number Diff line
@@ -32,17 +32,6 @@

#include "lib_isar_post_rend.h"

#ifndef SPLIT_REND_WITH_HEAD_ROT

int main( int argc, char **argv )
{
    (void) argc;
    (void) argv;
    ISAR_POST_REND_void_func();
    return 0;
}

#else

#include <assert.h>
#include <math.h>
@@ -1269,4 +1258,3 @@ int main(

#undef WMC_TOOL_SKIP
#endif /* SPLIT_REND_WITH_HEAD_ROT */
+0 −137

File changed.

Preview size limit exceeded, changes collapsed.

+0 −6
Original line number Diff line number Diff line
@@ -202,7 +202,6 @@ typedef struct _IVAS_JBM_TRACE_DATA
} IVAS_JBM_TRACE_DATA;


#ifdef SPLIT_REND_WITH_HEAD_ROT
/*----------------------------------------------------------------------------------*
 * Split rendering API constants, structures, and enums
 *----------------------------------------------------------------------------------*/
@@ -284,7 +283,6 @@ typedef struct _ISAR_SPLIT_REND_CONFIG
    int16_t lc3plus_highres;

} ISAR_SPLIT_REND_CONFIG_DATA, *ISAR_SPLIT_REND_CONFIG_HANDLE;
#endif

/*----------------------------------------------------------------------------------*
 * Renderer API structures and enums
@@ -325,9 +323,7 @@ typedef struct _IVAS_RENDER_CONFIG
    IVAS_RENDER_TYPE_OVERRIDE renderer_type_override;
#endif
    IVAS_ROOM_ACOUSTICS_CONFIG_DATA roomAcoustics;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    ISAR_SPLIT_REND_CONFIG_DATA split_rend_config;
#endif
    float directivity[IVAS_MAX_NUM_OBJECTS * 3];
    float distAtt[3];

@@ -337,9 +333,7 @@ typedef struct
{
    int16_t numSamplesPerChannel;
    int16_t numChannels;
#ifdef SPLIT_REND_WITH_HEAD_ROT
    int16_t is_cldfb;
#endif

} IVAS_REND_AudioBufferConfig;

+0 −8
Original line number Diff line number Diff line
@@ -54,12 +54,8 @@ int32_t get_delay(
    const int16_t enc_dec,         /* i  : encoder/decoder flag                */
    const int32_t io_fs,           /* i  : input/output sampling frequency     */
    const IVAS_FORMAT ivas_format, /* i  : IVAS format                         */
#ifdef SPLIT_REND_WITH_HEAD_ROT
    HANDLE_CLDFB_FILTER_BANK hCldfb,        /* i  : Handle of Cldfb analysis            */
    const int16_t flag_binaural_split_coded /* i  : split rendering on/off flag         */
#else
    HANDLE_CLDFB_FILTER_BANK hCldfb /* i  : Handle of Cldfb analysis            */
#endif
)
{
    int32_t delay = 0;
@@ -102,18 +98,14 @@ int32_t get_delay(
        {
            delay = IVAS_DEC_DELAY_NS;

#ifdef SPLIT_REND_WITH_HEAD_ROT
            if ( !flag_binaural_split_coded )
            {
#endif
                if ( hCldfb != NULL )
                {
                    /* compensate for filterbank delay */
                    delay += IVAS_FB_DEC_DELAY_NS;
                }
#ifdef SPLIT_REND_WITH_HEAD_ROT
            }
#endif

            if ( ivas_format == MASA_FORMAT || ivas_format == MASA_ISM_FORMAT )
            {
Loading