Commit fb9bc7ae authored by emerit's avatar emerit
Browse files

Merge branch 'main' into 2089-Limiter_attack_and_release_constants_differ_from_float_version

parents 8961bf9b b3940b5e
Loading
Loading
Loading
Loading
+5 −181
Original line number Original line Diff line number Diff line
@@ -138,7 +138,6 @@ typedef struct


} DecArguments;
} DecArguments;


#ifdef FIX_CREND_SIMPLIFY_CODE
typedef struct
typedef struct
{
{
    hrtfFileReader *hrtfReader;
    hrtfFileReader *hrtfReader;
@@ -156,7 +155,7 @@ typedef struct
    IVAS_AUDIO_CONFIG hrtf_set_audio_cfg;
    IVAS_AUDIO_CONFIG hrtf_set_audio_cfg;


} IVAS_DEC_HRTF_BINARY_WRAPPER;
} IVAS_DEC_HRTF_BINARY_WRAPPER;
#endif



/*------------------------------------------------------------------------------------------*
/*------------------------------------------------------------------------------------------*
 * Local functions prototypes
 * Local functions prototypes
@@ -164,14 +163,9 @@ typedef struct


static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
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 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 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 );
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




/*------------------------------------------------------------------------------------------*
/*------------------------------------------------------------------------------------------*
@@ -202,23 +196,15 @@ int main(
    RenderConfigReader *renderConfigReader = NULL;
    RenderConfigReader *renderConfigReader = NULL;
    int16_t *pcmBuf = NULL;
    int16_t *pcmBuf = NULL;
    IVAS_RENDER_FRAMESIZE asked_frame_size;
    IVAS_RENDER_FRAMESIZE asked_frame_size;
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary;
    IVAS_DEC_HRTF_BINARY_WRAPPER hHrtfBinary;
#else
    IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD = NULL;
    IVAS_DEC_HRTF_CREND_HANDLE *hSetOfHRTF = NULL;
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
#endif


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


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


    splitRendBits.bits_buf = splitRendBitsBuf;
    splitRendBits.bits_buf = splitRendBitsBuf;


@@ -603,112 +589,11 @@ int main(


    if ( arg.hrtfReaderEnabled )
    if ( arg.hrtfReaderEnabled )
    {
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        hHrtfBinary.hrtfReader = hrtfReader;
        hHrtfBinary.hrtfReader = hrtfReader;
        hHrtfBinary.hrtfFileName = arg.hrtfFileName;
        hHrtfBinary.hrtfFileName = arg.hrtfFileName;
        hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE;
        hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE;
        hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE;
        hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE;
        hHrtfBinary.hrtf_set_audio_cfg = IVAS_AUDIO_CONFIG_INVALID;
        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 ) );
            goto cleanup;
        }

#ifdef FIX_989_TD_REND_ROM
        if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, arg.output_Fs, hrtfReader ) ) != IVAS_ERR_OK )
#else
        if ( ( error = load_HRTF_binary( *hHrtfTD, hrtfReader ) ) != IVAS_ERR_OK )
#endif
        {
            if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
            {
                fprintf( stderr, "\nError in loading HRTF binary file %s \n\n", arg.hrtfFileName );
                goto cleanup;
            }
            else
            {
                destroy_td_hrtf( hHrtfTD );
            }
        }

        if ( ( error = IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfCRendHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }

        if ( ( error = create_SetOfHRTF_from_binary( *hSetOfHRTF, hrtfReader, arg.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", arg.hrtfFileName );
                goto cleanup;
            }
            else
            {
                destroy_SetOfHRTF( hSetOfHRTF );
            }
        }

        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 ) );
            goto cleanup;
        }

        if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, 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", arg.hrtfFileName );
                goto cleanup;
            }
            else
            {
                destroy_fastconv_hrtf( hHrtfFastConv );
            }
        }

        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 ) );
            goto cleanup;
        }

        if ( ( error = load_parambin_HRTF_from_binary( *hHrtfParambin, 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", arg.hrtfFileName );
                goto cleanup;
            }
            else
            {
                destroy_parambin_hrtf( hHrtfParambin );
            }
        }
        if ( ( error = IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics ) ) != IVAS_ERR_OK )
        {
            fprintf( stderr, "\nIVAS_DEC_GetHrtfHandle failed: %s\n\n", IVAS_DEC_GetErrorMessage( error ) );
            goto cleanup;
        }
        if ( ( error = load_reverb_binary( *hHrtfStatistics, arg.output_Fs, 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", arg.hrtfFileName );
                goto cleanup;
            }
            else
            {
                destroy_hrtf_statistics( hHrtfStatistics );
            }
        }
#endif
    }
    }


    /*------------------------------------------------------------------------------------------*
    /*------------------------------------------------------------------------------------------*
@@ -723,13 +608,11 @@ int main(
    }
    }


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


    /*-----------------------------------------------------------------*
    /*-----------------------------------------------------------------*
     * Decoding
     * Decoding
@@ -737,19 +620,11 @@ int main(


    if ( arg.voipMode )
    if ( arg.voipMode )
    {
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        error = decodeVoIP( arg, hBsReader, &hHrtfBinary, 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
    }
    }
    else
    else
    {
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        error = decodeG192( arg, hBsReader, &hHrtfBinary, 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
    }
    }


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


@@ -792,38 +663,17 @@ cleanup:


    if ( arg.hrtfReaderEnabled )
    if ( arg.hrtfReaderEnabled )
    {
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        destroy_td_hrtf( hHrtfBinary.hHrtfTD );
        destroy_td_hrtf( hHrtfBinary.hHrtfTD );
        destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
        destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
#else
        IVAS_DEC_GetHrtfHandle( hIvasDec, &hHrtfTD );
        if ( hHrtfTD != NULL )
        {
            destroy_td_hrtf( hHrtfTD );
        }
        IVAS_DEC_GetHrtfCRendHandle( hIvasDec, &hSetOfHRTF );
        if ( hSetOfHRTF != NULL )
        {
            destroy_SetOfHRTF( hSetOfHRTF );
        }
        IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics );
        destroy_hrtf_statistics( hHrtfStatistics );
#endif
    }
    }
#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD
#ifdef FIX_1990_SANITIZER_IN_REVERB_LOAD
    // TODO:
    // TODO:
    /* This free differs from float version.
    /* This free differs from float version.
       This is needed as HRTF statistics from ROM are currently converted from Word16 values to scaled Word32 values. */
       This is needed as HRTF statistics from ROM are currently converted from Word16 values to scaled Word32 values. */
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
    IVAS_DEC_HRTF_STATISTICS_HANDLE *hHrtfStatistics = NULL;
    IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics );
    IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics );
    destroy_hrtf_statistics( hHrtfStatistics );
    destroy_hrtf_statistics( hHrtfStatistics );
#else
    IVAS_DEC_GetHrtfStatisticsHandle( hIvasDec, &hHrtfStatistics );
    destroy_hrtf_statistics( hHrtfStatistics );
#endif
#endif
#endif

    IVAS_DEC_Close( &hIvasDec );
    IVAS_DEC_Close( &hIvasDec );
    CustomLsReader_close( &hLsCustomReader );
    CustomLsReader_close( &hLsCustomReader );
    hrtfFileReader_close( &hrtfReader );
    hrtfFileReader_close( &hrtfReader );
@@ -1959,9 +1809,7 @@ static ivas_error initOnFirstGoodFrame(
static ivas_error decodeG192(
static ivas_error decodeG192(
    DecArguments arg,
    DecArguments arg,
    BS_READER_HANDLE hBsReader,
    BS_READER_HANDLE hBsReader,
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary,
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary,
#endif
    RotFileReader *headRotReader,
    RotFileReader *headRotReader,
    RotFileReader *externalOrientationFileReader,
    RotFileReader *externalOrientationFileReader,
    RotFileReader *refRotReader,
    RotFileReader *refRotReader,
@@ -2243,7 +2091,6 @@ static ivas_error decodeG192(
                    goto cleanup;
                    goto cleanup;
                }
                }


#ifdef FIX_CREND_SIMPLIFY_CODE
                /* Read main parameters from the bitstream to set-up the decoder */
                /* Read main parameters from the bitstream to set-up the decoder */
                hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer;
                hHrtfBinary->binaural_renderer_old = hHrtfBinary->binaural_renderer;
                hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec;
                hHrtfBinary->binaural_renderer_sec_old = hHrtfBinary->binaural_renderer_sec;
@@ -2264,16 +2111,13 @@ static ivas_error decodeG192(
                        goto cleanup;
                        goto cleanup;
                    }
                    }
                }
                }
#endif


#ifdef FIX_HRTF_LOAD_API
                /* decode transport channels, do TSM and feed to renderer */
                /* decode transport channels, do TSM and feed to renderer */
                if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_DEC_GetSamplesDecoder( hIvasDec, isSplitRend, splitRendBits ) ) != IVAS_ERR_OK )
                {
                {
                    return error;
                    return error;
                }
                }


#endif
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_API
                /* Do the final preparations needed for rendering */
                /* Do the final preparations needed for rendering */
                if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK )
                if ( ( error = IVAS_DEC_PrepareRenderer( hIvasDec ) ) != IVAS_ERR_OK )
@@ -2677,9 +2521,7 @@ static ivas_error writeJbmTraceFileFrameWrapper( const void *data, void *writer
static ivas_error decodeVoIP(
static ivas_error decodeVoIP(
    DecArguments arg,
    DecArguments arg,
    BS_READER_HANDLE hBsReader,
    BS_READER_HANDLE hBsReader,
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf,
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf,
#endif
    RotFileReader *headRotReader,
    RotFileReader *headRotReader,
    RotFileReader *externalOrientationFileReader,
    RotFileReader *externalOrientationFileReader,
    RotFileReader *refRotReader,
    RotFileReader *refRotReader,
@@ -2729,13 +2571,11 @@ 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 } };
    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 vec_pos_update, vec_pos_len;
    int16_t nOutSamples = 0;
    int16_t nOutSamples = 0;
#ifdef FIX_CREND_SIMPLIFY_CODE
    bool bitstreamReadDone = false;
    bool bitstreamReadDone = false;
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_API
    bool parametersAvailableForEditing = false;
    bool parametersAvailableForEditing = false;
#endif
#endif
    uint16_t nSamplesRendered;
    uint16_t nSamplesRendered;
#endif


    vec_pos_update = 0;
    vec_pos_update = 0;
    if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK )
    if ( ( error = IVAS_DEC_GetRenderFramesizeMs( hIvasDec, &systemTimeInc_ms ) ) != IVAS_ERR_OK )
@@ -2853,9 +2693,7 @@ static ivas_error decodeVoIP(


    while ( 1 )
    while ( 1 )
    {
    {
#ifdef FIX_CREND_SIMPLIFY_CODE
        nSamplesRendered = 0;
        nSamplesRendered = 0;
#endif


        /* reference vector */
        /* reference vector */
        if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 )
        if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 )
@@ -3019,37 +2857,26 @@ static ivas_error decodeVoIP(




        /* decode and get samples */
        /* decode and get samples */
#ifdef FIX_HRTF_LOAD
        while ( nSamplesRendered < nOutSamples )
        while ( nSamplesRendered < nOutSamples )
        {
        {
#endif
#ifdef SUPPORT_JBM_TRACEFILE
#ifdef SUPPORT_JBM_TRACEFILE
#ifdef FIX_CREND_SIMPLIFY_CODE
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_API
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, &parametersAvailableForEditing ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered, &parametersAvailableForEditing ) ) != IVAS_ERR_OK )
#else
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter, &bitstreamReadDone, &nSamplesRendered ) ) != IVAS_ERR_OK )
#endif
#endif
#else
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms, writeJbmTraceFileFrameWrapper, jbmTraceWriter ) ) != IVAS_ERR_OK )
#endif
#else
#ifdef FIX_CREND_SIMPLIFY_CODE
#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_API
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone, &parametersAvailableForEditing ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone, &parametersAvailableForEditing ) ) != IVAS_ERR_OK )
#else
#else
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, (void *) pcmBuf, systemTime_ms, &bitstreamReadDone ) ) != IVAS_ERR_OK )
#endif
#endif
#else
        if ( ( error = IVAS_DEC_VoIP_GetSamples( hIvasDec, nOutSamples, pcmBuf, systemTime_ms ) ) != IVAS_ERR_OK )
#endif
#endif
#endif
            {
            {
                fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                fprintf( stderr, "\nError in IVAS_DEC_VoIP_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                goto cleanup;
                goto cleanup;
            }
            }


#ifdef FIX_CREND_SIMPLIFY_CODE
            if ( bitstreamReadDone == true )
            if ( bitstreamReadDone == true )
            {
            {
                /* Read main parameters from the bitstream to set-up the decoder */
                /* Read main parameters from the bitstream to set-up the decoder */
@@ -3073,16 +2900,14 @@ static ivas_error decodeVoIP(
                    }
                    }
                }
                }
            }
            }
#endif

#ifdef OBJ_EDITING_API
#ifdef OBJ_EDITING_API
            if ( parametersAvailableForEditing == true )
            if ( parametersAvailableForEditing == true )
            {
            {
                /* do the object editing here */
                /* do the object editing here */
            }
            }
#endif
#endif
#ifdef FIX_HRTF_LOAD
        } /* while ( nSamplesRendered < nOutSamples ) */
        } /* while ( nSamplesRendered < nOutSamples ) */
#endif


        /* write JBM Offset file entry */
        /* write JBM Offset file entry */
        if ( jbmOffsetWriter != NULL )
        if ( jbmOffsetWriter != NULL )
@@ -3368,7 +3193,6 @@ cleanup:
}
}




#ifdef FIX_CREND_SIMPLIFY_CODE
/*---------------------------------------------------------------------*
/*---------------------------------------------------------------------*
 * load_hrtf_from_file()
 * load_hrtf_from_file()
 *
 *
@@ -3541,5 +3365,5 @@ static ivas_error load_hrtf_from_file(


    return IVAS_ERR_OK;
    return IVAS_ERR_OK;
}
}
#endif

#undef WMC_TOOL_SKIP
#undef WMC_TOOL_SKIP
+0 −51
Original line number Original line Diff line number Diff line
@@ -715,11 +715,7 @@ static int16_t get_cldfb_in_flag(
    int16_t cldfb_in_flag;
    int16_t cldfb_in_flag;


    cldfb_in_flag = 0;
    cldfb_in_flag = 0;
#ifdef FIX_HRTF_LOAD
    if ( renderConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV )
    if ( renderConfig->split_rend_config.rendererSelection == IVAS_BIN_RENDERER_TYPE_FASTCONV )
#else
    if ( renderConfig->split_rend_config.rendererSelection == ISAR_SPLIT_REND_RENDERER_SELECTION_FASTCONV )
#endif
    {
    {
#ifdef DEBUGGING
#ifdef DEBUGGING
        cldfb_in_flag = 1;
        cldfb_in_flag = 1;
@@ -770,11 +766,7 @@ int main(
    SplitRendBFIFileReader *splitRendBFIReader = NULL;
    SplitRendBFIFileReader *splitRendBFIReader = NULL;
    Vector3PairFileReader *referenceVectorReader = NULL;
    Vector3PairFileReader *referenceVectorReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
    hrtfFileReader *hrtfFileReader = NULL;
#ifdef FIX_CREND_SIMPLIFY_CODE
    IVAS_DEC_HRTF_CREND_HANDLE *hHrtfCrend = NULL;
    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_FASTCONV_HANDLE *hHrtfFastConv = NULL;
    IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL;
    IVAS_DEC_HRTF_PARAMBIN_HANDLE *hHrtfParambin = NULL;
    IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD = NULL;
    IVAS_DEC_HRTF_TD_HANDLE *hHrtfTD = NULL;
@@ -1025,11 +1017,7 @@ int main(
                goto cleanup;
                goto cleanup;
            }
            }


#ifdef FIX_989_TD_REND_ROM
            if ( ( error = load_TDrend_HRTF_binary( *hHrtfTD, args.sampleRate, hrtfFileReader ) ) != IVAS_ERR_OK )
            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 )
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                {
@@ -1042,7 +1030,6 @@ int main(
                }
                }
            }
            }


#ifdef FIX_CREND_SIMPLIFY_CODE
            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hHrtfCrend ) ) != IVAS_ERR_OK )
            if ( ( error = IVAS_REND_GetHrtfCRendHandle( hIvasRend, &hHrtfCrend ) ) != IVAS_ERR_OK )
            {
            {
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) );
                fprintf( stderr, "\nIVAS_Rend_GetHrtfCRendHandle failed: %s\n\n", ivas_error_to_string( error ) );
@@ -1056,15 +1043,6 @@ int main(
            }
            }


            if ( ( error = load_Crend_HRTF_from_binary( *hHrtfCrend, hrtfFileReader, args.outConfig.audioConfig, hrtf_set_audio_cfg, args.sampleRate ) ) != IVAS_ERR_OK )
            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 ) );
                goto cleanup;
            }

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


@@ -1087,11 +1061,7 @@ int main(
                goto cleanup;
                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 )
            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 )
                if ( error != IVAS_ERR_BINARY_FILE_WITHOUT_BINAURAL_RENDERER_DATA )
                {
                {
@@ -2203,18 +2173,7 @@ cleanup:
    RotationFileReader_close( &externalOrientationFileReader );
    RotationFileReader_close( &externalOrientationFileReader );
    RotationFileReader_close( &referenceRotReader );
    RotationFileReader_close( &referenceRotReader );
    Vector3PairFileReader_close( &referenceVectorReader );
    Vector3PairFileReader_close( &referenceVectorReader );
#ifdef FIX_CREND_SIMPLIFY_CODE
    destroy_td_hrtf( hHrtfTD );
#else
    if ( hSetOfHRTF != NULL && *hSetOfHRTF != NULL )
    {
        destroy_SetOfHRTF( hSetOfHRTF );
    }
    if ( hHrtfTD != NULL && *hHrtfTD != NULL )
    {
    destroy_td_hrtf( hHrtfTD );
    destroy_td_hrtf( hHrtfTD );
    }
#endif
    destroy_hrtf_statistics( hHrtfStatistics );
    destroy_hrtf_statistics( hHrtfStatistics );
    IVAS_REND_Close( &hIvasRend );
    IVAS_REND_Close( &hIvasRend );
    IsmPositionProvider_close( positionProvider );
    IsmPositionProvider_close( positionProvider );
@@ -2805,9 +2764,7 @@ static CmdlnArgs defaultArgs(
    const char *executableName )
    const char *executableName )
{
{
    CmdlnArgs args;
    CmdlnArgs args;
#ifdef FIX_CREND_SIMPLIFY_CODE
    int16_t i;
    int16_t i;
#endif


    strncpy( args.executableName, executableName, RENDERER_MAX_CLI_ARG_LENGTH );
    strncpy( args.executableName, executableName, RENDERER_MAX_CLI_ARG_LENGTH );
    clearString( args.inputFilePath );
    clearString( args.inputFilePath );
@@ -2824,16 +2781,12 @@ static CmdlnArgs defaultArgs(
    args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
    args.outConfig.audioConfig = IVAS_AUDIO_CONFIG_INVALID;
    args.outConfig.outSetupCustom.num_spk = 0;
    args.outConfig.outSetupCustom.num_spk = 0;
    args.outConfig.outSetupCustom.num_lfe = 0;
    args.outConfig.outSetupCustom.num_lfe = 0;
#ifdef FIX_CREND_SIMPLIFY_CODE
    for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i )
    for ( i = 0; i < RENDERER_MAX_SBA_INPUTS; ++i )
    {
    {
        args.inConfig.ambisonicsBuses[i].audioConfig = IVAS_AUDIO_CONFIG_INVALID;
        args.inConfig.ambisonicsBuses[i].audioConfig = IVAS_AUDIO_CONFIG_INVALID;
    }
    }


    for ( i = 0; i < RENDERER_MAX_ISM_INPUTS + RENDERER_MAX_MASA_INPUTS; ++i )
    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] );
        clearString( args.inMetadataFilePaths[i] );
    }
    }
@@ -2870,11 +2823,7 @@ static CmdlnArgs defaultArgs(
    clearString( args.inLfePanningMatrixFile );
    clearString( args.inLfePanningMatrixFile );
    args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
    args.render_framesize = IVAS_RENDER_FRAMESIZE_20MS;
    args.syncMdDelay = 0;
    args.syncMdDelay = 0;
#ifdef FIX_CREND_SIMPLIFY_CODE
    for ( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i )
    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;
        args.directivityPatternId[i] = 65535;
    }
    }
+1 −28
Original line number Original line Diff line number Diff line
@@ -194,13 +194,6 @@ void tcx_arith_scale_envelope(
    Word16 statesi, bits;
    Word16 statesi, bits;
    Word32 mean, a, s, L_tmp;
    Word32 mean, a, s, L_tmp;
    Word16 mean_e, tmp, tmp2;
    Word16 mean_e, tmp, tmp2;
#ifndef ISSUE_1836_replace_overflow_libcom
#ifdef BASOP_NOGLOB_DECLARE_LOCAL
    Flag Overflow = 0;
    move32();
#endif
#endif



    lob_bits = 0;
    lob_bits = 0;
    move16();
    move16();
@@ -225,11 +218,7 @@ void tcx_arith_scale_envelope(


        tmp = norm_l( env[k] );
        tmp = norm_l( env[k] );
        tmp2 = sub( 15, tmp );
        tmp2 = sub( 15, tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
        tmp = Inv16( round_fx_sat( L_shl( env[k], tmp ) ), &tmp2 ); /* exp(tmp2) */
        tmp = Inv16( round_fx_sat( L_shl( env[k], tmp ) ), &tmp2 ); /* exp(tmp2) */
#else
        tmp = Inv16( round_fx_o( L_shl_o( env[k], tmp, &Overflow ), &Overflow ), &tmp2 ); /* exp(tmp2) */
#endif
        ienv[k] = L_shl( L_deposit_h( tmp ), sub( tmp2, 15 ) );     /* Q16 */
        ienv[k] = L_shl( L_deposit_h( tmp ), sub( tmp2, 15 ) );     /* Q16 */
        move32();
        move32();
        mean = L_add( mean, ienv[k] ); /* Q16 */
        mean = L_add( mean, ienv[k] ); /* Q16 */
@@ -262,11 +251,7 @@ void tcx_arith_scale_envelope(
    b_e = add( b_e, mean_e );
    b_e = add( b_e, mean_e );


    /* scale = (-b + (float)sqrt(b*b - 4.0f*a*0.035f)) / (2.0f * a); */
    /* scale = (-b + (float)sqrt(b*b - 4.0f*a*0.035f)) / (2.0f * a); */
#ifdef ISSUE_1836_replace_overflow_libcom
    tmp = round_fx_sat( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16_1( a, -4588 /*-4.0f*0.035f Q15*/ ), a_e, &tmp2 ) );
    tmp = round_fx_sat( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16_1( a, -4588 /*-4.0f*0.035f Q15*/ ), a_e, &tmp2 ) );
#else
    tmp = round_fx_o( BASOP_Util_Add_Mant32Exp( L_mult( b, b ), shl( b_e, 1 ), Mpy_32_16_1( a, -4588 /*-4.0f*0.035f Q15*/ ), a_e, &tmp2 ), &Overflow );
#endif


    IF( tmp <= 0 )
    IF( tmp <= 0 )
    {
    {
@@ -281,11 +266,7 @@ void tcx_arith_scale_envelope(


    tmp2 = BASOP_Util_Add_MantExp( negate( b ), b_e, tmp, tmp2, &scale ); /* exp(scale) */
    tmp2 = BASOP_Util_Add_MantExp( negate( b ), b_e, tmp, tmp2, &scale ); /* exp(scale) */
    scale = BASOP_Util_Divide1616_Scale( scale, round_fx( a ), &tmp );
    scale = BASOP_Util_Divide1616_Scale( scale, round_fx( a ), &tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
    scale = shl_sat( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ) ); /* Q15 */
    scale = shl_sat( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ) ); /* Q15 */
#else
    scale = shl_o( scale, sub( sub( add( tmp, tmp2 ), a_e ), 1 ), &Overflow ); /* Q15 */
#endif


    /* iscale = 1.0f / scale; */
    /* iscale = 1.0f / scale; */
    iscale_e = 0;
    iscale_e = 0;
@@ -334,11 +315,7 @@ void tcx_arith_scale_envelope(
                L_tmp = L_add( L_tmp, L_shl( Mpy_32_16_1( env[k], mult_r( 1147 /*0.035f Q15*/, iscale ) ), iscale_e ) ); /* Q16 */
                L_tmp = L_add( L_tmp, L_shl( Mpy_32_16_1( env[k], mult_r( 1147 /*0.035f Q15*/, iscale ) ), iscale_e ) ); /* Q16 */


                tmp = norm_l( L_tmp );
                tmp = norm_l( L_tmp );
#ifdef ISSUE_1836_replace_overflow_libcom
                statesi = mult_r( statesi, round_fx_sat( L_shl( L_tmp, tmp ) ) );
                statesi = mult_r( statesi, round_fx_sat( L_shl( L_tmp, tmp ) ) );
#else
                statesi = mult_r( statesi, round_fx_o( L_shl_o( L_tmp, tmp, &Overflow ), &Overflow ) );
#endif
                bits = add( bits, sub( 15, tmp ) );
                bits = add( bits, sub( 15, tmp ) );


                tmp = norm_s( statesi );
                tmp = norm_s( statesi );
@@ -425,11 +402,7 @@ void tcx_arith_scale_envelope(
    *s_env_e = sub( add( 15, iscale_e ), tmp );
    *s_env_e = sub( add( 15, iscale_e ), tmp );
    move16();
    move16();
    BASOP_SATURATE_WARNING_OFF_EVS;
    BASOP_SATURATE_WARNING_OFF_EVS;
#ifdef ISSUE_1836_replace_overflow_libcom
    a = L_shl_sat( 1265000, sub( 15, *s_env_e ) );
    a = L_shl_sat( 1265000, sub( 15, *s_env_e ) );
#else
    a = L_shl_o( 1265000, sub( 15, *s_env_e ), &Overflow );
#endif
    BASOP_SATURATE_WARNING_ON_EVS;
    BASOP_SATURATE_WARNING_ON_EVS;


    FOR( k = 0; k < L_frame; k++ )
    FOR( k = 0; k < L_frame; k++ )
Loading