Commit 26432a61 authored by emerit's avatar emerit
Browse files

initial version

parent 0b4901bd
Loading
Loading
Loading
Loading
+311 −2
Original line number Diff line number Diff line
@@ -135,6 +135,25 @@ typedef struct

} DecArguments;

#ifdef FIX_CREND_SIMPLIFY_CODE
typedef struct
{
    hrtfFileReader *hrtfReader;
    char *hrtfFileName;

    IVAS_DEC_HRTF_HANDLE *hHrtfTD;

    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics;

    IVAS_BIN_RENDERER_TYPE binaural_renderer;
    IVAS_BIN_RENDERER_TYPE binaural_renderer_old;
    IVAS_BIN_RENDERER_TYPE binaural_renderer_sec;
    IVAS_BIN_RENDERER_TYPE binaural_renderer_sec_old;

    IVAS_AUDIO_CONFIG hrtf_set_audio_cfg;

} IVAS_DEC_HRTF_BINARY_WRAPPER;
#endif

/*------------------------------------------------------------------------------------------*
 * Local functions prototypes
@@ -142,8 +161,14 @@ typedef struct

static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
#ifdef FIX_CREND_SIMPLIFY_CODE
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, ISAR_SPLIT_REND_BITS_DATA *splitRendBits, IVAS_DEC_HANDLE hIvasDec, int16_t *pcmBuf );
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 );
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 );
#else
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 );
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec );
#endif


/*------------------------------------------------------------------------------------------*
@@ -174,15 +199,24 @@ int main(
    RenderConfigReader *renderConfigReader = NULL;
    int16_t *pcmBuf = NULL;
    IVAS_RENDER_FRAMESIZE asked_frame_size;
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary;
#else
    IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
#endif

#ifdef WMOPS
    reset_wmops();
    reset_mem( USE_BYTES );
#endif

#ifdef FIX_CREND_SIMPLIFY_CODE
    hHrtfBinary.hHrtfTD = NULL;         /* just to avoid compilation warning */
    hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */
#endif

    splitRendBits.bits_buf = splitRendBitsBuf;

    /*------------------------------------------------------------------------------------------*
@@ -566,6 +600,13 @@ int main(

    if ( arg.hrtfReaderEnabled )
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        hHrtfBinary.hrtfReader = hrtfReader;
        hHrtfBinary.hrtfFileName = arg.hrtfFileName;
        hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE;
        hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE;
        hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID;
#else
        if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
@@ -660,6 +701,7 @@ int main(
                destroy_hrtf_statistics( hHrtfStatistics );
            }
        }
#endif
    }

    /*------------------------------------------------------------------------------------------*
@@ -674,18 +716,32 @@ int main(
    }

    pcmBuf = malloc( pcmBufSize * sizeof( int16_t ) );

#ifdef FIX_CREND_SIMPLIFY_CODE
    if ( pcmBuf == NULL )
    {
        fprintf( stdout, "Error: Unable to allocate memory for output buffer.\n" );
        goto cleanup;
    }
#endif
    /*-----------------------------------------------------------------*
     * Decoding
     *-----------------------------------------------------------------*/

    if ( arg.voipMode )
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
#else
        error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
#endif
    }
    else
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        error = decodeG192( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf );
#else
        error = decodeG192( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf );
#endif
    }

    if ( error == IVAS_ERR_OK || error == IVAS_ERR_END_OF_FILE )
@@ -701,7 +757,11 @@ int main(
    }
    else
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        fprintf( stderr, "\nDecoding finished prematurely: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
#else
        fprintf( stdout, "Decoding finished prematurely\n\n" );
#endif
        goto cleanup;
    }

@@ -724,6 +784,10 @@ cleanup:

    if ( arg.hrtfReaderEnabled )
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        destroy_td_hrtf( hHrtfBinary.hHrtfTD );
        destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
#else
        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );
        if ( hHrtfTD != NULL )
        {
@@ -734,8 +798,14 @@ cleanup:
        {
            destroy_SetOfHRTF( hSetOfHRTF );
        }
        IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics );
        destroy_hrtf_statistics();
#endif
    }

#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary.hHrtfStatistics );
    destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
#endif
    IVAS_DEC_Close( &hIvasDec );
    CustomLsReader_close( &hLsCustomReader );
    hrtfFileReader_close( &hrtfReader );
@@ -1836,6 +1906,9 @@ static ivas_error initOnFirstGoodFrame(
static ivas_error decodeG192(
    DecArguments arg,
    BS_READER_HANDLE hBsReader,
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary,
#endif
    RotFileReader *headRotReader,
    RotFileReader *externalOrientationFileReader,
    RotFileReader *refRotReader,
@@ -2116,6 +2189,29 @@ static ivas_error decodeG192(
                    fprintf( stderr, "\nError: could not feed frame to decoder: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }

#ifdef FIX_CREND_SIMPLIFY_CODE
                /* Load HRTF binary file data */
                if ( arg.hrtfReaderEnabled )
                {
                    /* Read main parameters from the bitstream to set-up the decoder */
                    hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer;
                    hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec;
                    if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->binaural_renderer_sec, &hHrtfBinary->hrtf_set_audio_cfg ) ) != IVAS_ERR_OK )
                    {
                        return error;
                    }

                    /* Placeholder for memory reallocation */
                    /* ... */

                    if ( ( error = load_hrtf_from_file( hHrtfBinary, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
                    }
                }
#endif
            }

            if ( isSplitRend )
@@ -2511,6 +2607,9 @@ static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer
static ivas_error decodeVoIP(
    DecArguments arg,
    BS_READER_HANDLE hBsReader,
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf,
#endif
    RotFileReader *headRotReader,
    RotFileReader *externalOrientationFileReader,
    RotFileReader *refRotReader,
@@ -2560,6 +2659,9 @@ static ivas_error decodeVoIP(
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 } };
    int16_t vec_pos_update, vec_pos_len;
    int16_t nOutSamples = 0;
#ifdef FIX_CREND_SIMPLIFY_CODE
    bool bitstreamReadDone = false;
#endif

    vec_pos_update = 0;
    if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK )
@@ -2841,15 +2943,49 @@ static ivas_error decodeVoIP(

        /* decode and get samples */
#ifdef SUPPORT_JBM_TRACEFILE
#ifdef FIX_CREND_SIMPLIFY_CODE
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone ) ) != IVAS_ERR_OK )
#else
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef FIX_CREND_SIMPLIFY_CODE
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone ) ) != 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 ) );
            goto cleanup;
        }

#ifdef FIX_CREND_SIMPLIFY_CODE
        if ( bitstreamReadDone == true )
        {
            /* Load HRTF binary file data */
            if ( arg.hrtfReaderEnabled )
            {
                /* Read main parameters from the bitstream to set-up the decoder */
                hHrtf->binaural_renderer_old = hHrtf->binaural_renderer;
                hHrtf->binaural_renderer_sec_old = hHrtf->binaural_renderer_sec;
                if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtf->binaural_renderer, &hHrtf->binaural_renderer_sec, &hHrtf->hrtf_set_audio_cfg ) ) != IVAS_ERR_OK )
                {
                    return error;
                }

                /* Placeholder for memory reallocation */
                /* ... */

                if ( ( error = load_hrtf_from_file( hHrtf, hIvasDec, arg.outputConfig, arg.output_Fs ) ) != IVAS_ERR_OK )
                {
                    fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
            }
        }
#endif

        /* write JBM Offset file entry */
        if ( jbmOffsetWriter != NULL )
        {
@@ -3133,5 +3269,178 @@ cleanup:
    return error;
}

#ifdef FIX_CREND_SIMPLIFY_CODE
/*---------------------------------------------------------------------*
 * load_hrtf_from_file()
 *
 * Load HRTF coefficients from external binary file
 *---------------------------------------------------------------------*/

static ivas_error load_hrtf_from_file(
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, /* i/o: HRTF binary wrapper handle   */
    IVAS_DEC_HANDLE hIvasDec,                  /* i/o: IVAS decoder handle          */
    const IVAS_AUDIO_CONFIG OutputConfig,      /* i  : output audio configuration   */
    const int32_t output_Fs                    /* i  : output sampling rate         */
)
{
    ivas_error error;
    IVAS_BIN_RENDERER_TYPE binaural_renderer, binaural_renderer_sec;

    if ( hHrtfBinary == NULL || hIvasDec == NULL )
    {
        return IVAS_ERR_UNEXPECTED_NULL_POINTER;
    }

    binaural_renderer = hHrtfBinary->binaural_renderer;
    binaural_renderer_sec = hHrtfBinary->binaural_renderer_sec;

    if ( ( binaural_renderer != hHrtfBinary->binaural_renderer_old ) ||
         ( binaural_renderer_sec != hHrtfBinary->binaural_renderer_sec_old ) ||
         ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) )
    {
        /*------------------------------------------------------------------------------------------*
         * Release HRTF binary data
         *------------------------------------------------------------------------------------------*/

        if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && binaural_renderer_sec != IVAS_BIN_RENDERER_TYPE_TDREND && hHrtfBinary->hHrtfTD != NULL )
        {
            destroy_td_hrtf( hHrtfBinary->hHrtfTD );
        }

        if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        /*------------------------------------------------------------------------------------------*
         * Load HRTF binary data
         *------------------------------------------------------------------------------------------*/

        if ( ( error = IVAS_DEC_HRTF_binary_open( hIvasDec, binaural_renderer ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( ( error = IVAS_DEC_HRTF_binary_open( hIvasDec, binaural_renderer_sec ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer_sec == IVAS_BIN_RENDERER_TYPE_TDREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT )
        {
            if ( ( error = IVAS_DEC_GetHrtfTDrendHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfTDrendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
            }

            if ( ( error = load_TDrend_HRTF_binary( *hHrtfBinary->hHrtfTD, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
                {
                    destroy_td_hrtf( hHrtfBinary->hHrtfTD );
                }
            }
        }

        if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT )
        {
            IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL;
            if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hHrtfCrend ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
            }

            if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hHrtfBinary->hrtfReader, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, output_Fs ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
                {
                    destroy_crend_hrtf( hHrtfCrend );
                }
            }
        }

        if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT )
        {
            IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL;
            if ( ( error = IVAS_DEC_GetHrtfFastConvHandle( hIvasDec, &hHrtfFastConv ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfFastConvHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
            }

            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, OutputConfig, hHrtfBinary->hrtf_set_audio_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
                {
                    destroy_fastconv_hrtf( hHrtfFastConv );
                }
            }
        }

        if ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_PARAMBIN || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT )
        {
            IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL;
            if ( ( error = IVAS_DEC_GetHrtfParamBinHandle( hIvasDec, &hHrtfParambin ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfParamBinHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
            }

            if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
                {
                    destroy_parambin_hrtf( hHrtfParambin );
                }
            }
        }
    }

    if ( hHrtfBinary->hHrtfStatistics == NULL && ( binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV || binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND ) && OutputConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
    {
        if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfStatisticsHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            return error;
        }

        if ( ( error = load_reverb_binary( *hHrtfBinary->hHrtfStatistics, output_Fs, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
        {
            if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
            {
                fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                return error;
            }
            else
            {
                destroy_hrtf_statistics( hHrtfBinary->hHrtfStatistics );
            }
        }
    }

    return IVAS_ERR_OK;
}
#endif
#undef WMC_TOOL_SKIP
+46 −1
Original line number Diff line number Diff line
@@ -744,7 +744,11 @@ int main(
    SplitRendBFIFileReader *splitRendBFIReader = NULL;
    Vector3PairFileReader *referenceVectorReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL;
#else
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
#endif
    IVAS_DEC_HRTF_FASTCONV_HANDLE *hHrtfFastConv = NULL;
    IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL;
    IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
@@ -992,7 +996,11 @@ int main(
                goto cleanup;
            }

#ifdef FIX_CREND_SIMPLIFY_CODE
            if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK )
#else
            if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfFileReader ) ) != IVAS_ERR_OK )
#endif
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
@@ -1005,7 +1013,20 @@ int main(
                }
            }

#ifdef FIX_CREND_SIMPLIFY_CODE
            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hHrtfCrend ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) );
                goto cleanup;
            }
            IVAS_AUDIO_CONFIG hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_7_1_4;
            if ( args.inConfig.ambisonicsBuses->audioConfig != IVAS_AUDIO_CONFIG_INVALID && args.outConfig.audioConfig != IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                hrtf_set_audio_cfg = args.inConfig.ambisonicsBuses->audioConfig;
            }

            if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hrtfFileReader, args.outConfig.audioConfig, hrtf_set_audio_cfg, args.sampleRate ) ) != IVAS_ERR_OK )
#else
            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hSetOfHRTF ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) );
@@ -1013,6 +1034,7 @@ int main(
            }

            if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfFileReader, args.sampleRate ) ) != IVAS_ERR_OK )
#endif
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
@@ -1021,7 +1043,11 @@ int main(
                }
                else
                {
#ifdef FIX_CREND_SIMPLIFY_CODE
                    destroy_crend_hrtf( hHrtfCrend );
#else
                    destroy_SetOfHRTF( hSetOfHRTF );
#endif
                }
            }

@@ -1031,7 +1057,11 @@ int main(
                goto cleanup;
            }

#ifdef FIX_CREND_SIMPLIFY_CODE
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, args.outConfig.audioConfig, args.inConfig.ambisonicsBuses->audioConfig, hrtfFileReader ) ) != IVAS_ERR_OK )
#else
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hrtfFileReader ) ) != IVAS_ERR_OK )
#endif
            {
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
@@ -2128,6 +2158,9 @@ cleanup:
    RotationFileReader_close( &externalOrientationFileReader );
    RotationFileReader_close( &referenceRotReader );
    Vector3PairFileReader_close( &referenceVectorReader );
#ifdef FIX_CREND_SIMPLIFY_CODE
    destroy_td_hrtf( hHrtfTD );
#else
    if ( hSetOfHRTF != NULL && *hSetOfHRTF != NULL )
    {
        destroy_SetOfHRTF( hSetOfHRTF );
@@ -2136,6 +2169,7 @@ cleanup:
    {
        destroy_td_hrtf( hHrtfTD );
    }
#endif
    destroy_hrtf_statistics( hHrtfStatistics );
    IVAS_REND_Close( &hIvasRend );
    IsmPositionProvider_close( positionProvider );
@@ -2706,6 +2740,9 @@ static CmdlnArgs defaultArgs(
    const char *executableName )
{
    CmdlnArgs args;
#ifdef FIX_CREND_SIMPLIFY_CODE
    int16_t i;
#endif

    strncpy( args.executableName, executableName, RENDERER_MAX_CLI_ARG_LENGTH );
    clearString( args.inputFilePath );
@@ -2722,8 +2759,13 @@ static CmdlnArgs defaultArgs(
    args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
    args.outConfig.outSetupCustom.num_spk = 0;
    args.outConfig.outSetupCustom.num_lfe = 0;
    args.inConfig.ambisonicsBuses->audioConfig = IVAS_AUDIO_CONFIG_INVALID;

#ifdef FIX_CREND_SIMPLIFY_CODE
    for ( i = 0; i < RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS; ++i )
#else
    for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
#endif
    {
        clearString( args.inMetadataFilePaths[i] );
    }
@@ -2760,8 +2802,11 @@ static CmdlnArgs defaultArgs(
    clearString( args.inLfePanningMatrixFile );
    args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
    args.syncMdDelay = 0;

#ifdef FIX_CREND_SIMPLIFY_CODE
    for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
#else
    for ( int32_t i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
#endif
    {
        args.directivityPatternId[i] = 65535;
    }
+20 −0
Original line number Diff line number Diff line
@@ -178,11 +178,19 @@ typedef enum
typedef struct ivas_masa_metadata_frame_struct *IVAS_MASA_METADATA_HANDLE;
typedef struct ivas_masa_decoder_ext_out_meta_struct *IVAS_MASA_DECODER_EXT_OUT_META_HANDLE;

#ifdef FIX_CREND_SIMPLIFY_CODE
typedef struct ivas_hrtf_TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE;
typedef struct ivas_hrtf_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
typedef struct ivas_hrtf_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE;
typedef struct ivas_hrtf_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE;
typedef struct ivas_hrtf_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE;
#else
typedef struct TDREND_HRFILT_FiltSet_struct *IVAS_DEC_HRTF_HANDLE;
typedef struct ivas_hrtfs_crend_structure *IVAS_DEC_HRTF_CREND_HANDLE;
typedef struct ivas_hrtfs_fastconv_struct *IVAS_DEC_HRTF_FASTCONV_HANDLE;
typedef struct ivas_hrtfs_parambin_struct *IVAS_DEC_HRTF_PARAMBIN_HANDLE;
typedef struct ivas_hrtfs_statistics_struct *IVAS_DEC_HRTF_STATISTICS_HANDLE;
#endif
typedef struct cldfb_filter_bank_struct *IVAS_CLDFB_FILTER_BANK_HANDLE;

typedef struct ivas_LS_setup_custom *IVAS_LSSETUP_CUSTOM_HANDLE;
@@ -216,6 +224,18 @@ typedef struct _IVAS_JBM_TRACE_DATA

} IVAS_JBM_TRACE_DATA;

#ifdef FIX_CREND_SIMPLIFY_CODE
typedef enum _ivas_binaural_renderer_type
{
    IVAS_BIN_RENDERER_TYPE_NONE,
    IVAS_BIN_RENDERER_TYPE_CREND,
    IVAS_BIN_RENDERER_TYPE_FASTCONV,
    IVAS_BIN_RENDERER_TYPE_PARAMBIN,
    IVAS_BIN_RENDERER_TYPE_TDREND,
    IVAS_BIN_RENDERER_TYPE_DEFAULT,

} IVAS_BIN_RENDERER_TYPE;
#endif

/*----------------------------------------------------------------------------------*
 * Split rendering API constants, structures, and enums
+7 −0
Original line number Diff line number Diff line
@@ -1695,6 +1695,13 @@ typedef enum
#define ONE_BY_360_Q15                          ( 91 )          // Q15
#define ONE_BY_180_Q31                          ( 11930465 )    // Q31

#ifdef FIX_CREND_SIMPLIFY_CODE
#define RESAMPLE_FACTOR_16_48 ( 10922 )  // Q15
#define RESAMPLE_FACTOR_32_48 ( 21845 ) // Q15
#define RESAMPLE_FACTOR_16_48_FX ( 5461 )  // Q14
#define RESAMPLE_FACTOR_32_48_FX ( 10922 ) // Q14
#endif

/* ----- Enums - TD Renderer ----- */

typedef enum
+7 −0

File changed.

Preview size limit exceeded, changes collapsed.

Loading