Commit fcc475fe authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

attempt to simplify the FastConv HRTF set loading conditions

parent 84f8f5d5
Loading
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ typedef struct
    IVAS_BIN_RENDERER_TYPE binaural_renderer_sec_old;

#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM
    IVAS_AUDIO_CONFIG fastConv_set_cfg;
    BINAURAL_INPUT_AUDIO_CONFIG fastConv_set_cfg;
#else
    IVAS_AUDIO_CONFIG intern_audio_config;
    int16_t room_reverb_flag;
@@ -188,7 +188,7 @@ static bool parseCmdlIVAS_dec( int16_t argc, char **argv, DecArguments *arg );
static void usage_dec( void );
static ivas_error decodeG192( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtf, 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 *hHrtf, RotFileReader *headRotReader, RotFileReader *externalOrientationFileReader, RotFileReader *refRotReader, Vector3PairFileReader *referenceVectorReader, IVAS_DEC_HANDLE hIvasDec );
static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, const int32_t output_Fs );
static ivas_error IVAS_DEC_LoadHrtfFromFile( IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary, IVAS_DEC_HANDLE hIvasDec, IVAS_AUDIO_CONFIG out_config, const int32_t output_Fs );
#ifdef DEBUGGING
static ivas_error printBitstreamInfoVoip( DecArguments arg, BS_READER_HANDLE hBsReader, IVAS_DEC_HANDLE hIvasDec );
static int16_t app_own_random( int16_t *seed );
@@ -733,7 +733,7 @@ int main(
        hHrtfBinary.binaural_renderer = IVAS_BIN_RENDERER_TYPE_NONE;
        hHrtfBinary.binaural_renderer_sec = IVAS_BIN_RENDERER_TYPE_NONE;
#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM
        hHrtfBinary.fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID;
        hHrtfBinary.fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_INVALID;
#else
        hHrtfBinary.room_reverb_flag = 0;
        hHrtfBinary.intern_audio_config = IVAS_AUDIO_CONFIG_INVALID;
@@ -2389,7 +2389,7 @@ static ivas_error decodeG192(
                /* Load HRTF binary file data */
                if ( arg.hrtfReaderEnabled )
                {
                    if ( ( error = IVAS_DEC_LoadHrtfFromFile( hHrtfBinary, hIvasDec, arg.output_Fs ) ) != IVAS_ERR_OK )
                    if ( ( error = IVAS_DEC_LoadHrtfFromFile( 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;
@@ -3300,7 +3300,7 @@ static ivas_error decodeVoIP(
                /* 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( 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;
@@ -3700,6 +3700,7 @@ static IVAS_DEC_FORCED_REND_MODE parseForcedRendModeDec(
static ivas_error IVAS_DEC_LoadHrtfFromFile(
    IVAS_DEC_HRTF_BINARY_WRAPPER *hHrtfBinary,
    IVAS_DEC_HANDLE hIvasDec,
    IVAS_AUDIO_CONFIG out_config,
    const int32_t output_Fs )
{
    ivas_error error;
@@ -3804,7 +3805,7 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(
            }

#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->fastConv_set_cfg, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->fastConv_set_cfg, out_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
#else
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, hHrtfBinary->room_reverb_flag, hHrtfBinary->intern_audio_config, hHrtfBinary->hrtfReader ) ) != IVAS_ERR_OK )
#endif
+1 −1
Original line number Diff line number Diff line
@@ -946,7 +946,7 @@ int main(
            }

#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, IVAS_AUDIO_CONFIG_EXTERNAL, hrtfFileReader ) ) != IVAS_ERR_OK )
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED, args.outConfig.audioConfig, hrtfFileReader ) ) != IVAS_ERR_OK )
#else
            if ( ( error = load_fastconv_HRTF_from_binary( *hHrtfFastConv, 0, IVAS_AUDIO_CONFIG_INVALID, hrtfFileReader ) ) != IVAS_ERR_OK )
#endif
+11 −0
Original line number Diff line number Diff line
@@ -97,6 +97,17 @@ typedef enum _IVAS_AUDIO_CONFIG

} IVAS_AUDIO_CONFIG;

typedef enum
{
    BINAURAL_INPUT_AUDIO_CONFIG_INVALID,
    BINAURAL_INPUT_AUDIO_CONFIG_COMBINED, /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA3,     /* HOA3 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA2,     /* HOA2 */
    BINAURAL_INPUT_AUDIO_CONFIG_FOA,      /* FOA */
    BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED /* Not used */

} BINAURAL_INPUT_AUDIO_CONFIG;


/*----------------------------------------------------------------------------------*
 * Common API structures and enums
+0 −11
Original line number Diff line number Diff line
@@ -1499,17 +1499,6 @@ typedef enum

#define BINAURAL_COHERENCE_DIFFERENCE_BINS      9                           /* Number of bins for direction-dependent diffuse-field binaural coherence */

typedef enum 
{
    BINAURAL_INPUT_AUDIO_CONFIG_INVALID,
    BINAURAL_INPUT_AUDIO_CONFIG_COMBINED,       /* 5_1, 5_1_2, 5_1_4, 7_1, 7_1_4 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA3,           /*  HOA3 */
    BINAURAL_INPUT_AUDIO_CONFIG_HOA2,           /* HOA2 */
    BINAURAL_INPUT_AUDIO_CONFIG_FOA,            /* FOA */
    BINAURAL_INPUT_AUDIO_CONFIG_UNDEFINED       /* Not used */

} BINAURAL_INPUT_AUDIO_CONFIG;

#define HEADROT_ORDER                           3
#define HEADROT_SHMAT_DIM                       ( ( HEADROT_ORDER + 1 ) * ( HEADROT_ORDER + 1 ) )
#define HEADROT_SHMAT_DIM2                      ( HEADROT_SHMAT_DIM * HEADROT_SHMAT_DIM )
+13 −27
Original line number Diff line number Diff line
@@ -916,7 +916,7 @@ ivas_error IVAS_DEC_ReadFormat(
    IVAS_BIN_RENDERER_TYPE *binaural_renderer,     /* o  : binaural renderer type                   */
    IVAS_BIN_RENDERER_TYPE *binaural_renderer_sec, /* o  : secondary binaural renderer type         */
#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM
    IVAS_AUDIO_CONFIG *fastConv_set_cfg /* o  : HRTF set audio config. for FastConv rend.*/
    BINAURAL_INPUT_AUDIO_CONFIG *fastConv_set_cfg /* o  : HRTF set audio config. for FastConv rend.*/
#else
    int16_t *room_reverb_flag,             /* o  : room reverb flag                         */
    IVAS_AUDIO_CONFIG *intern_audio_config /* o  : internal audio configuration             */
@@ -1018,44 +1018,30 @@ ivas_error IVAS_DEC_ReadFormat(
        }

#ifdef FIX_1226_FASTCONV_HRTF_LOADING_OPTIM
        *fastConv_set_cfg = IVAS_AUDIO_CONFIG_INVALID;
        *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_INVALID;
        if ( *binaural_renderer == IVAS_BIN_RENDERER_TYPE_FASTCONV )
        {
            if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT )
            {
                if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL ||
                     output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
                {
                    /* SHD transformed HRIRs */
                    *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3;
                }
                else if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                /* SHD HRIRs */
                *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_HOA3;

                if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                {
                    /* BRIRs */
                    *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR;
                    *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_COMBINED;
                }
            }
            else if ( st_ivas->ivas_format == MC_FORMAT )
            {
                /* BRIRs */
                *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR;

                if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
            {
                /* HRIRs */
                    *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL;
                }

                if ( st_ivas->hDecoderConfig->Opt_Headrotation )
                {
                    /* SHD transformed HRIRs for low complexity rotation */
                    *fastConv_set_cfg = IVAS_AUDIO_CONFIG_HOA3;
                *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_COMBINED;

                    if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                if ( ( st_ivas->hDecoderConfig->Opt_Headrotation ) &&
                     !( st_ivas->mc_mode == MC_MODE_PARAMUPMIX && output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
                {
                        /* BRIRs */
                        *fastConv_set_cfg = IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR;
                    }
                    /* SHD HRIRs for low complexity rotation */
                    *fastConv_set_cfg = BINAURAL_INPUT_AUDIO_CONFIG_HOA3;
                }
            }
        }
Loading