Commit ae4bfd49 authored by vaclav's avatar vaclav
Browse files

FIX_1227_Crend_HRTF_LOADING_OPTIM2

parent 080129be
Loading
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -807,9 +807,7 @@ cleanup:
    if ( arg.hrtfReaderEnabled )
    {
        destroy_td_hrtf( hHrtfBinary.hHrtfTD );
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
        destroy_SetOfHRTF( hHrtfBinary.hSetOfHRTF );
#endif
        destroy_hrtf_statistics( hHrtfBinary.hHrtfStatistics );
    }

+1 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#define TMP_FIX_1119_SPLIT_RENDERING_VOIP               /* FhG: Add error check for unsupported config: split rendering with VoIP mode */
#define FIX_1227_Crend_HRTF_LOADING_OPTIM               /* VA: issue 1227: for Crend binaural renderer in decoder, load only HTRT coefficient set that is needed */
#define FIX_1227_Crend_HRTF_LOADING_OPTIM2

/* #################### End BE switches ################################## */

+93 −20
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ static ivas_error ivas_hrtf_open(
    return IVAS_ERR_OK;
}


#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
/*-------------------------------------------------------------------------
 * ivas_hrtf_close()
 *
@@ -161,6 +161,7 @@ static void ivas_hrtf_close(

    return;
}
#endif

/*-------------------------------------------------------------------------
 * ivas_rend_initCrend()
@@ -178,7 +179,11 @@ static ivas_error ivas_rend_initCrend(
#endif
    const int32_t output_Fs )
{
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    int16_t i, j, tmp, tmp2;
#else
    int16_t i, j, tmp;
#endif
    int16_t nchan_in;
    IVAS_REND_AudioConfigType inConfigType;
    HRTFS_HANDLE hHrtf;
@@ -205,6 +210,9 @@ static ivas_error ivas_rend_initCrend(
        if ( hSetOfHRTF != NULL && ext_rend_flag == 0 )
        {
            /* HRTF set loaded from binary file */
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
            hHrtf = hSetOfHRTF->hHRTF_Crend;
#else
            if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                hHrtf = hSetOfHRTF->hHRTF_brir_combined;
@@ -218,6 +226,7 @@ static ivas_error ivas_rend_initCrend(
            {
                hHrtf = hSetOfHRTF->hHRTF_hrir_hoa3;
            }
#endif

            hHrtf->init_from_rom = 0;
        }
@@ -756,6 +765,15 @@ static ivas_error ivas_rend_initCrend(
#endif
                if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
                    if ( hSetOfHRTF->hHRTF_Crend == NULL )
                    {
                        return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters " );
                    }
                    hHrtf->latency_s = hSetOfHRTF->hHRTF_Crend->latency_s;
                    hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_Crend->max_num_iterations;
                    hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_Crend->index_frequency_max_diffuse;
#else
                if ( hSetOfHRTF->hHRTF_brir_combined == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters " );
@@ -763,7 +781,9 @@ static ivas_error ivas_rend_initCrend(
                hHrtf->latency_s = hSetOfHRTF->hHRTF_brir_combined->latency_s;
                hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_brir_combined->max_num_iterations;
                hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_brir_combined->index_frequency_max_diffuse;
#endif
                }
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM2
                else
                {
                    if ( hSetOfHRTF->hHRTF_hrir_combined == NULL )
@@ -774,9 +794,17 @@ static ivas_error ivas_rend_initCrend(
                    hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_hrir_combined->max_num_iterations;
                    hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_hrir_combined->index_frequency_max_diffuse;
                }
#endif

                for ( j = 0; j < BINAURAL_CHANNELS; j++ )
                {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
                    hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_Crend->num_iterations_diffuse[j];
                    hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_Crend->pIndex_frequency_max_diffuse[j];
                    hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_diffuse_re[j];
                    hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_diffuse_im[j];

#else
                if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                {
                    hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations_diffuse[j];
@@ -791,6 +819,7 @@ static ivas_error ivas_rend_initCrend(
                    hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_re[j];
                    hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_diffuse_im[j];
                }
#endif
                }
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
            }
@@ -801,15 +830,23 @@ static ivas_error ivas_rend_initCrend(
                for ( i = 5; i < hHrtf->max_num_ir; i++ )
                {
                    tmp = channelIndex_CICP12[i];
                    int16_t tmp2 = channelIndex_CICP14[i];
                    tmp2 = channelIndex_CICP14[i];

                    for ( j = 0; j < BINAURAL_CHANNELS; j++ )
                    {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
                        hHrtf->inv_diffuse_weight[j][tmp2] = hSetOfHRTF->hHRTF_Crend->inv_diffuse_weight[j][tmp];
                        hHrtf->num_iterations[tmp2][j] = hSetOfHRTF->hHRTF_Crend->num_iterations[tmp][j];
                        hHrtf->pIndex_frequency_max[tmp2][j] = hSetOfHRTF->hHRTF_Crend->pIndex_frequency_max[tmp][j];
                        hHrtf->pOut_to_bin_re[tmp2][j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_re[tmp][j];
                        hHrtf->pOut_to_bin_im[tmp2][j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_im[tmp][j];
#else
                        hHrtf->inv_diffuse_weight[j][tmp2] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight[j][tmp];
                        hHrtf->num_iterations[tmp2][j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations[tmp][j];
                        hHrtf->pIndex_frequency_max[tmp2][j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max[tmp][j];
                        hHrtf->pOut_to_bin_re[tmp2][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_re[tmp][j];
                        hHrtf->pOut_to_bin_im[tmp2][j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_im[tmp][j];
#endif
                    }
                }
            }
@@ -855,6 +892,13 @@ static ivas_error ivas_rend_initCrend(

                for ( j = 0; j < BINAURAL_CHANNELS; j++ )
                {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
                    hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_Crend->inv_diffuse_weight[j][tmp];
                    hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_Crend->num_iterations[tmp][j];
                    hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_Crend->pIndex_frequency_max[tmp][j];
                    hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_re[tmp][j];
                    hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_im[tmp][j];
#else
                    if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                    {
                        hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight[j][tmp];
@@ -871,11 +915,37 @@ static ivas_error ivas_rend_initCrend(
                        hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_re[tmp][j];
                        hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_im[tmp][j];
                    }
#endif
                }
            }
        }
        else if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS )
        {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
            hHrtf->latency_s = hSetOfHRTF->hHRTF_Crend->latency_s;
            hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_Crend->max_num_iterations;
            hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_Crend->index_frequency_max_diffuse;

            for ( i = 0; i < hHrtf->max_num_ir; i++ )
            {
                for ( j = 0; j < BINAURAL_CHANNELS; j++ )
                {
                    hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_Crend->inv_diffuse_weight[j][i];
                    hHrtf->num_iterations[i][j] = hSetOfHRTF->hHRTF_Crend->num_iterations[i][j];
                    hHrtf->pIndex_frequency_max[i][j] = hSetOfHRTF->hHRTF_Crend->pIndex_frequency_max[i][j];
                    hHrtf->pOut_to_bin_re[i][j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_re[i][j];
                    hHrtf->pOut_to_bin_im[i][j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_im[i][j];
                }
            }
            for ( j = 0; j < BINAURAL_CHANNELS; j++ )
            {
                hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_Crend->num_iterations_diffuse[j];
                hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_Crend->pIndex_frequency_max_diffuse[j];
                hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_diffuse_re[j];
                hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_Crend->pOut_to_bin_diffuse_im[j];
            }

#else
            if ( inConfig == IVAS_AUDIO_CONFIG_HOA3 )
            {
                if ( hSetOfHRTF->hHRTF_hrir_hoa3 == NULL )
@@ -967,6 +1037,7 @@ static ivas_error ivas_rend_initCrend(
            {
                return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported renderer type in Crend" );
            }
#endif
        }
    }

@@ -1522,11 +1593,13 @@ void ivas_rend_closeCrend(
        return;
    }

#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
    if ( ( *pCrend )->hHrtfCrend != NULL )
    {
        ivas_hrtf_close( &( *pCrend )->hHrtfCrend );
    }

#endif
    for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
    {
        hCrend = ( *pCrend )->hCrend[pos_idx];
+4 −0
Original line number Diff line number Diff line
@@ -98,11 +98,15 @@ ivas_error ivas_HRTF_CRend_binary_open(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for set of HRTF binary!" );
    }

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
    ( *hSetOfHRTF )->hHRTF_Crend = NULL;
#else
    ( *hSetOfHRTF )->hHRTF_hrir_combined = NULL;
    ( *hSetOfHRTF )->hHRTF_hrir_hoa3 = NULL;
    ( *hSetOfHRTF )->hHRTF_hrir_hoa2 = NULL;
    ( *hSetOfHRTF )->hHRTF_hrir_foa = NULL;
    ( *hSetOfHRTF )->hHRTF_brir_combined = NULL;
#endif

    return IVAS_ERR_OK;
}
+4 −0
Original line number Diff line number Diff line
@@ -1246,11 +1246,15 @@ typedef struct ivas_binaural_rendering_struct

typedef struct ivas_hrtfs_crend_structure
{
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
    HRTFS_DATA *hHRTF_Crend;
#else
    HRTFS_DATA *hHRTF_hrir_combined;
    HRTFS_DATA *hHRTF_hrir_hoa3;
    HRTFS_DATA *hHRTF_hrir_hoa2;
    HRTFS_DATA *hHRTF_hrir_foa;
    HRTFS_DATA *hHRTF_brir_combined;
#endif

} HRTFS_CREND, *HRTFS_CREND_HANDLE;

Loading