Commit 6d509288 authored by vaclav's avatar vaclav
Browse files

merge FIX_1227_Crend_HRTF_LOADING_OPTIM2 into FIX_1227_Crend_HRTF_LOADING_OPTIM

parent 870bcf3d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -161,7 +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 ################################## */

+123 −169
Original line number Diff line number Diff line
@@ -206,32 +206,10 @@ static ivas_error ivas_rend_initCrend(
    if ( hHrtf == NULL )
    {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
        if ( hSetOfHRTF != NULL && hSetOfHRTF->hHRTF_Crend != NULL && ext_rend_flag == 0 )
#else
        if ( hSetOfHRTF != NULL && ext_rend_flag == 0 )
#endif
        {
            /* 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;
            }
            else
            {
                hHrtf = hSetOfHRTF->hHRTF_hrir_combined;
            }

            if ( hHrtf == NULL )
            {
                hHrtf = hSetOfHRTF->hHRTF_hrir_hoa3;
            }
#endif

            hHrtf->init_from_rom = 0;
        }
        else
@@ -243,11 +221,7 @@ static ivas_error ivas_rend_initCrend(
            }

            hHrtf->init_from_rom = 1;
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
            if ( hSetOfHRTF != NULL && hSetOfHRTF->hHRTF_Crend != NULL )
#else
            if ( hSetOfHRTF != NULL )
#endif
            {
                hHrtf->init_from_rom = 0;
            }
@@ -762,23 +736,15 @@ static ivas_error ivas_rend_initCrend(
    }
    else
    {
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
        hHrtf->init_from_rom = 0;
#endif
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
        if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
        {
            hHrtf->max_num_ir -= 1; /* subtract LFE */
            hHrtf->gain_lfe = GAIN_LFE;
        }

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
        if ( ext_rend_flag == 1 )
        {
#endif
#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM2
                if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                {
#endif
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
            if ( hSetOfHRTF->hHRTF_Crend == NULL )
            {
                return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters " );
@@ -786,55 +752,14 @@ static ivas_error ivas_rend_initCrend(
            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 " );
            }
            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 )
                    {
                        return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters" );
                    }
                    hHrtf->latency_s = hSetOfHRTF->hHRTF_hrir_combined->latency_s;
                    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];
                    hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max_diffuse[j];
                    hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_re[j];
                    hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_im[j];
            }
                else
                {
                    hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations_diffuse[j];
                    hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max_diffuse[j];
                    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
        }

        if ( inConfig == IVAS_AUDIO_CONFIG_7_1 && ext_rend_flag == 0 )
@@ -847,34 +772,14 @@ 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][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
                        if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                        {
                            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];
                        }
                        else
                        {
                            hHrtf->inv_diffuse_weight[j][tmp2] = hSetOfHRTF->hHRTF_hrir_combined->inv_diffuse_weight[j][tmp];
                            hHrtf->num_iterations[tmp2][j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations[tmp][j];
                            hHrtf->pIndex_frequency_max[tmp2][j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max[tmp][j];
                            hHrtf->pOut_to_bin_re[tmp2][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_re[tmp][j];
                            hHrtf->pOut_to_bin_im[tmp2][j] = hSetOfHRTF->hHRTF_hrir_combined->pOut_to_bin_im[tmp][j];
                        }
#endif
                }
            }
        }
#endif

        for ( i = 0; i < hHrtf->max_num_ir; i++ )
        {
@@ -884,7 +789,6 @@ static ivas_error ivas_rend_initCrend(
            }
            else if ( inConfig == IVAS_AUDIO_CONFIG_7_1 )
            {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
                if ( ext_rend_flag == 0 )
                {
                    tmp = channelIndex_CICP14[i];
@@ -893,9 +797,6 @@ static ivas_error ivas_rend_initCrend(
                {
                    tmp = channelIndex_CICP12[i];
                }
#else
                    tmp = channelIndex_CICP12[i];
#endif
            }
            else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_2 )
            {
@@ -909,6 +810,10 @@ static ivas_error ivas_rend_initCrend(
            {
                tmp = channelIndex_CICP19[i];
            }
            else if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS )
            {
                tmp = i;
            }
            else
            {
                return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" );
@@ -916,7 +821,6 @@ 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];

@@ -938,7 +842,83 @@ static ivas_error ivas_rend_initCrend(
                    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
        hHrtf->init_from_rom = 0;
        if ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED )
        {
            hHrtf->max_num_ir -= 1; /* subtract LFE */
            hHrtf->gain_lfe = GAIN_LFE;

            if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
            {
                if ( hSetOfHRTF->hHRTF_brir_combined == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters " );
                }
                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;
            }
            else
            {
                if ( hSetOfHRTF->hHRTF_hrir_combined == NULL )
                {
                    return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Invalid function parameters" );
                }
                hHrtf->latency_s = hSetOfHRTF->hHRTF_hrir_combined->latency_s;
                hHrtf->max_num_iterations = hSetOfHRTF->hHRTF_hrir_combined->max_num_iterations;
                hHrtf->index_frequency_max_diffuse = hSetOfHRTF->hHRTF_hrir_combined->index_frequency_max_diffuse;
            }

            for ( j = 0; j < BINAURAL_CHANNELS; j++ )
            {
                if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                {
                    hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->num_iterations_diffuse[j];
                    hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_brir_combined->pIndex_frequency_max_diffuse[j];
                    hHrtf->pOut_to_bin_diffuse_re[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_re[j];
                    hHrtf->pOut_to_bin_diffuse_im[j] = hSetOfHRTF->hHRTF_brir_combined->pOut_to_bin_diffuse_im[j];
                }
                else
                {
                    hHrtf->num_iterations_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->num_iterations_diffuse[j];
                    hHrtf->pIndex_frequency_max_diffuse[j] = hSetOfHRTF->hHRTF_hrir_combined->pIndex_frequency_max_diffuse[j];
                    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];
                }
            }

            for ( i = 0; i < hHrtf->max_num_ir; i++ )
            {
                if ( inConfig == IVAS_AUDIO_CONFIG_5_1 )
                {
                    tmp = channelIndex_CICP6[i];
                }
                else if ( inConfig == IVAS_AUDIO_CONFIG_7_1 )
                {
                    tmp = channelIndex_CICP12[i];
                }
                else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_2 )
                {
                    tmp = channelIndex_CICP14[i];
                }
                else if ( inConfig == IVAS_AUDIO_CONFIG_5_1_4 )
                {
                    tmp = channelIndex_CICP16[i];
                }
                else if ( inConfig == IVAS_AUDIO_CONFIG_7_1_4 )
                {
                    tmp = channelIndex_CICP19[i];
                }
                else
                {
                    return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: Channel configuration not specified!\n\n" );
                }

                for ( j = 0; j < BINAURAL_CHANNELS; j++ )
                {
                    if ( outConfig == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
                    {
                        hHrtf->inv_diffuse_weight[j][i] = hSetOfHRTF->hHRTF_brir_combined->inv_diffuse_weight[j][tmp];
@@ -955,37 +935,11 @@ 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 )
@@ -1077,8 +1031,8 @@ static ivas_error ivas_rend_initCrend(
            {
                return IVAS_ERROR( IVAS_ERR_INTERNAL, "Unsupported renderer type in Crend" );
            }
#endif
        }
#endif
    }

    hHrtf->same_inv_diffuse_weight = 1;
+1 −1
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ 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
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    ( *hSetOfHRTF )->hHRTF_Crend = NULL;
#else
    ( *hSetOfHRTF )->hHRTF_hrir_combined = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -1246,7 +1246,7 @@ typedef struct ivas_binaural_rendering_struct

typedef struct ivas_hrtfs_crend_structure
{
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    HRTFS_DATA *hHRTF_Crend;
#else
    HRTFS_DATA *hHRTF_hrir_combined;
+2 −2
Original line number Diff line number Diff line
@@ -2152,7 +2152,7 @@ ivas_error create_SetOfHRTF_from_binary(
            hHRTF = NULL;
            if ( hrtf_header.frequency == output_Fs )
            {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
                hHRTF = &( ( *hSetOfHRTF ).hHRTF_Crend );
#else
            if ( hrtf_header.rend_type == HRTF_READER_RENDERER_BINAURAL_MIXER_CONV )
@@ -2283,7 +2283,7 @@ void destroy_SetOfHRTF(
{
    if ( ( hSetOfHRTF != NULL ) && ( *hSetOfHRTF != NULL ) )
    {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM2
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
        destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_Crend ) );
#else
        destroy_HRTF( &( ( *hSetOfHRTF )->hHRTF_hrir_combined ) );