Commit f3650acf authored by vaclav's avatar vaclav
Browse files

rename 'hHrtf' to 'hHrtfBinary'

parent 71f3a648
Loading
Loading
Loading
Loading
+44 −45
Original line number Diff line number Diff line
@@ -162,7 +162,6 @@ typedef struct
} DecArguments;

#ifdef FIX_HRTF_LOAD

typedef struct
{
    hrtfFileReader *hrtfReader;
@@ -199,7 +198,7 @@ static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS
static ivas_error decodeVoIP( DecArguments arg, BS_READER_HANDLE hBsReader, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec );
#endif
#ifdef FIX_HRTF_LOAD
static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_WRAPPER *hHrtf, IVAS_DEC_HANDLE hIvasDec, const int32_t output_Fs );
static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const int32_t output_Fs );
#endif

#ifdef DEBUGGING
@@ -237,7 +236,7 @@ int main(
    int16_t *pcmBuf = NULL;
    IVAS_RENDER_FRAMESIZE asked_frame_size;
#ifdef FIX_HRTF_LOAD
    IVAS_DEC_HRTF_WRAPPER hHrtf;
    IVAS_DEC_HRTF_WRAPPER hHrtfBinary;
#else
    IVAS_DEC_HRTF_HANDLE *hHrtfTD = NULL;
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
@@ -260,12 +259,9 @@ int main(
#endif

#ifdef FIX_HRTF_LOAD
    hHrtf.binaural_renderer = ISAR_SPLIT_REND_RENDERER_SELECTION_NONE;
    hHrtf.hHrtfTD = NULL;         /* just to avoid compilation warning */
    hHrtf.hSetOfHRTF = NULL;      /* just to avoid compilation warning */
    hHrtf.hHrtfStatistics = NULL; /* just to avoid compilation warning */
    hHrtf.room_reverb_flag = 0;
    hHrtf.intern_audio_config = IVAS_AUDIO_CONFIG_INVALID;
    hHrtfBinary.hHrtfTD = NULL;         /* just to avoid compilation warning */
    hHrtfBinary.hSetOfHRTF = NULL;      /* just to avoid compilation warning */
    hHrtfBinary.hHrtfStatistics = NULL; /* just to avoid compilation warning */
#endif

    splitRendBits.bits_buf = splitRendBitsBuf;
@@ -776,14 +772,17 @@ int main(
    if ( arg.hrtfReaderEnabled )
    {
#ifdef FIX_HRTF_LOAD
        hHrtf.hrtfReader = hrtfReader;
        hHrtf.hrtfFileName = arg.hrtfFileName;
        hHrtfBinary.hrtfReader = hrtfReader;
        hHrtfBinary.hrtfFileName = arg.hrtfFileName;
        hHrtfBinary.binaural_renderer = ISAR_SPLIT_REND_RENDERER_SELECTION_NONE;
        hHrtfBinary.room_reverb_flag = 0;
        hHrtfBinary.intern_audio_config = IVAS_AUDIO_CONFIG_INVALID;
#ifndef FIX_HRTF_LOAD_JBM
        if ( arg.voipMode )
        {
            hHrtf.binaural_renderer = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT;
            hHrtf.binaural_renderer_old = ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT;
            if ( ( error = IVAS_DEC_LoadHrtfFromFile( &hHrtf, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_LoadHrtfFromFile( &hHrtfBinary, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
@@ -910,7 +909,7 @@ int main(
    if ( arg.voipMode )
    {
#ifdef FIX_HRTF_LOAD_JBM
        error = decodeVoIP( arg, hBsReader, &hHrtf, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
#else
        error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
#endif
@@ -918,7 +917,7 @@ int main(
    else
    {
#ifdef FIX_HRTF_LOAD
        error = decodeG192( arg, hBsReader, &hHrtf, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, &splitRendBits, hIvasDec, pcmBuf );
        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
@@ -974,9 +973,9 @@ cleanup:
    if ( arg.hrtfReaderEnabled )
    {
#ifdef FIX_HRTF_LOAD
        destroy_td_hrtf( hHrtf.hHrtfTD );
        destroy_SetOfHRTF( hHrtf.hSetOfHRTF );
        destroy_hrtf_statistics( hHrtf.hHrtfStatistics );
        destroy_td_hrtf( hHrtfBinary.hHrtfTD );
        destroy_SetOfHRTF( hHrtfBinary.hSetOfHRTF );
        destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
#else
        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );
        destroy_td_hrtf( hHrtfTD );
@@ -2180,7 +2179,7 @@ static ivas_error decodeG192(
    DecArguments arg,
    BS_READER_HANDLE hBsReader,
#ifdef FIX_HRTF_LOAD
    IVAS_DEC_HRTF_WRAPPER *hHrtf,
    IVAS_DEC_HRTF_WRAPPER *hHrtfBinary,
#endif
    RotFileReader *headRotReader,
    RotFileReader *externalOrientationFileReader,
@@ -2558,8 +2557,8 @@ static ivas_error decodeG192(

#ifdef FIX_HRTF_LOAD
                /* Read main parameters from the bitstream to set-up the decoder */
                hHrtf->binaural_renderer_old = hHrtf->binaural_renderer;
                if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtf->binaural_renderer, &hHrtf->room_reverb_flag, &hHrtf->intern_audio_config ) ) != IVAS_ERR_OK )
                hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer;
                if ( ( error = IVAS_DEC_ReadFormat( hIvasDec, &hHrtfBinary->binaural_renderer, &hHrtfBinary->room_reverb_flag, &hHrtfBinary->intern_audio_config ) ) != IVAS_ERR_OK )
                {
                    return error;
                }
@@ -2570,7 +2569,7 @@ static ivas_error decodeG192(
                /* Load HRTF binary file data */
                if ( arg.hrtfReaderEnabled )
                {
                    if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtf, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK )
                    if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtfBinary, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK )
                    {
                        fprintf( stderr, "\nIVAS_DEC_LoadHrtfFromFile failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                        goto cleanup;
@@ -3874,21 +3873,21 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec(
 *---------------------------------------------------------------------*/

static ivas_error IVAS_DEC_LoadHrtfFromFile(
    IVAS_DEC_HRTF_WRAPPER *hHrtf,
    IVAS_DEC_HRTF_WRAPPER *hHrtfBinary,
    IVAS_DEC_HANDLE hIvasDec,
    const int32_t output_Fs )
{
    ivas_error error;
    ISAR_SPLIT_REND_RENDERER_SELECTION binaural_renderer;

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

    binaural_renderer = hHrtf->binaural_renderer;
    binaural_renderer = hHrtfBinary->binaural_renderer;

    if ( ( binaural_renderer != hHrtf->binaural_renderer_old ) || ( binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT ) )
    if ( ( binaural_renderer != hHrtfBinary->binaural_renderer_old ) || ( binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT ) )
    {
        /*------------------------------------------------------------------------------------------*
         * Release HRTF binary data
@@ -3896,15 +3895,15 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(

        if ( !( binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND || binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT ) )
        {
            destroy_td_hrtf( hHrtf->hHrtfTD );
            destroy_td_hrtf( hHrtfBinary->hHrtfTD );
        }

        if ( !( binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_CREND || binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT ) )
        {
            destroy_SetOfHRTF( hHrtf->hSetOfHRTF );
            destroy_SetOfHRTF( hHrtfBinary->hSetOfHRTF );
        }

        if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtf->binaural_renderer_old ) ) != IVAS_ERR_OK )
        if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK )
        {
            return error;
        }
@@ -3920,44 +3919,44 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(

        if ( binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_TDREND || binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT )
        {
            if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtf->hHrtfTD ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfBinary->hHrtfTD ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
            }

            if ( ( error = load_HRTF_binary( *hHrtf->hHrtfTD, hHrtf->hrtfReader ) ) != IVAS_ERR_OK )
            if ( ( error = load_HRTF_binary( *hHrtfBinary->hHrtfTD, 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", hHrtf->hrtfFileName );
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
                {
                    destroy_td_hrtf( hHrtf->hHrtfTD );
                    destroy_td_hrtf( hHrtfBinary->hHrtfTD );
                }
            }
        }

        if ( binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_CREND || binaural_renderer == ISAR_SPLIT_REND_RENDERER_SELECTION_DEFAULT )
        {
            if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hHrtf->hSetOfHRTF ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hHrtfBinary->hSetOfHRTF ) ) != IVAS_ERR_OK )
            {
                fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
                return error;
            }

            if ( ( error = create_SetOfHRTF_from_binary( *hHrtf->hSetOfHRTF, hHrtf->hrtfReader, output_Fs ) ) != IVAS_ERR_OK )
            if ( ( error = create_SetOfHRTF_from_binary( *hHrtfBinary->hSetOfHRTF, hHrtfBinary->hrtfReader, 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", hHrtf->hrtfFileName );
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
                {
                    destroy_SetOfHRTF( hHrtf->hSetOfHRTF );
                    destroy_SetOfHRTF( hHrtfBinary->hSetOfHRTF );
                }
            }
        }
@@ -3971,11 +3970,11 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(
                return error;
            }

            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtf->room_reverb_flag, hHrtf->intern_audio_config, hHrtf->hrtfReader ) ) != IVAS_ERR_OK )
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->room_reverb_flag, hHrtfBinary->intern_audio_config, 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", hHrtf->hrtfFileName );
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
@@ -3994,11 +3993,11 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(
                return error;
            }

            if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, hHrtf->hrtfReader ) ) != IVAS_ERR_OK )
            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", hHrtf->hrtfFileName );
                    fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", hHrtfBinary->hrtfFileName );
                    return error;
                }
                else
@@ -4009,24 +4008,24 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(
        }
    }

    if ( hHrtf->hHrtfStatistics == NULL )
    if ( hHrtfBinary->hHrtfStatistics == NULL )
    {
        if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtf->hHrtfStatistics ) ) != IVAS_ERR_OK )
        if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfBinary->hHrtfStatistics ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            return error;
        }

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