Commit 2fe15be6 authored by vaclav's avatar vaclav
Browse files

- define ivas_hrtf_init() globally instead of twice as local

- comments
parent b6d98cb2
Loading
Loading
Loading
Loading
+18 −13
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@
 * Initialize hHrtf handle
 *------------------------------------------------------------------------*/

static ivas_error ivas_hrtf_init(
ivas_error ivas_hrtf_init(
    HRTFS_DATA *hHrtf /* i/o: HRTF handle     */
)
{
@@ -105,6 +105,7 @@ static ivas_error ivas_hrtf_open(
)
{
    HRTFS_HANDLE hHrtf;
    ivas_error error;

    if ( *hHrtf_out == NULL )
    {
@@ -113,7 +114,10 @@ static ivas_error ivas_hrtf_open(
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for SPAR decoder\n" );
        }

        ivas_hrtf_init( hHrtf );
        if ( ( error = ivas_hrtf_init( hHrtf ) ) != IVAS_ERR_OK )
        {
            return error;
        }

        *hHrtf_out = hHrtf;
    }
@@ -1098,15 +1102,16 @@ static ivas_error ivas_rend_crendConvolver(
 *-----------------------------------------------------------------------------------------*/

ivas_error ivas_rend_crendProcess(
    const CREND_WRAPPER *pCrend,
    const AUDIO_CONFIG inConfig,
    const AUDIO_CONFIG outConfig,
    DECODER_CONFIG_HANDLE hDecoderConfig,
    HEAD_TRACK_DATA_HANDLE hHeadTrackData,
    IVAS_OUTPUT_SETUP_HANDLE hIntSetup,
    EFAP_HANDLE hEFAPdata,
    const CREND_WRAPPER *pCrend,                 /* i/o: Crend wrapper handle               */
    const AUDIO_CONFIG inConfig,                 /* i  : input audio configuration          */
    const AUDIO_CONFIG outConfig,                /* i  : output audio configuration         */
    const DECODER_CONFIG_HANDLE hDecoderConfig,  /* i  : decoder config. structure          */
    const HEAD_TRACK_DATA_HANDLE hHeadTrackData, /* i  : Head tracking data structure       */
    const IVAS_OUTPUT_SETUP_HANDLE hIntSetup,    /* i  : internal setup handle              */
    const EFAP_HANDLE hEFAPdata,                 /* i  : EFAP handle                        */
    float output[][L_FRAME48k],                  /* i/o: input/output audio channels        */
    const int32_t output_Fs )
    const int32_t output_Fs                      /* i  : ouput sampling rate                */
)
{
    int16_t i, subframe_idx, output_frame, subframe_len;
    int16_t nchan_out;
@@ -1135,10 +1140,9 @@ ivas_error ivas_rend_crendProcess(
    subframe_len = output_frame / MAX_PARAM_SPATIAL_SUBFRAMES;
    for ( subframe_idx = 0; subframe_idx < MAX_PARAM_SPATIAL_SUBFRAMES; subframe_idx++ )
    {
        /* Rotation */
        if ( hDecoderConfig && hDecoderConfig->Opt_Headrotation && hHeadTrackData && hHeadTrackData->num_quaternions >= 0 )
        {
            /* Orientation tracking */

            /* Rotation in SHD for:
                MC with elevation (5_1_2 / 5_1_4 / 7_1_4) -> BINAURAL
                SBA SPAR -> BINAURAL or BINAURAL_ROOM
@@ -1154,6 +1158,7 @@ ivas_error ivas_rend_crendProcess(
            }
        }

        /* Reverberation */
        if ( ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_CHANNEL_BASED ) || ( inConfigType == IVAS_REND_AUDIO_CONFIG_TYPE_AMBISONICS ) )
        {
            if ( ( error = ivas_rend_crendConvolver( pCrend, inRendConfig, outRendConfig, output, pcm_tmp, output_Fs, subframe_idx ) ) != IVAS_ERR_OK )
+20 −19
Original line number Diff line number Diff line
@@ -182,6 +182,10 @@ void ivas_HRTF_binary_close(
    TDREND_HRFILT_FiltSet_t **hHrtfTD                           /* i/o: TD renderer HRTF handle                 */
);

ivas_error ivas_hrtf_init(
    HRTFS_DATA *hHrtf                                           /* i/o: HRTF handle                             */
);

ivas_error ivas_HRTF_fastconv_binary_open(
    HRTFS_FASTCONV **hHrtfFastConv                              /* i/o: FASTCONV HRTF structure                 */
);
@@ -486,20 +490,17 @@ ivas_error ivas_rend_initCrendWrapper(
    CREND_WRAPPER_HANDLE *pCrend );

ivas_error ivas_rend_crendProcess(
    const CREND_WRAPPER *pCrend,
    const AUDIO_CONFIG inConfig,
    const AUDIO_CONFIG outConfig,
    DECODER_CONFIG_HANDLE hDecoderConfig,
    HEAD_TRACK_DATA_HANDLE hHeadTrackData,
    IVAS_OUTPUT_SETUP_HANDLE hIntSetup,
    EFAP_HANDLE hEFAPdata,
    const CREND_WRAPPER *pCrend,                                /* i/o: Crend wrapper handle                    */
    const AUDIO_CONFIG inConfig,                                /* i  : input audio configuration               */
    const AUDIO_CONFIG outConfig,                               /* i  : output audio configuration              */
    const DECODER_CONFIG_HANDLE hDecoderConfig,                 /* i  : decoder config. structure               */
    const HEAD_TRACK_DATA_HANDLE hHeadTrackData,                /* i  : Head tracking data structure            */
    const IVAS_OUTPUT_SETUP_HANDLE hIntSetup,                   /* i  : internal setup handle                   */
    const EFAP_HANDLE hEFAPdata,                                /* i  : EFAP handle                             */
    float output[][L_FRAME48k],                                 /* i/o: input/output audio channels             */
    const int32_t output_Fs 
    const int32_t output_Fs                                     /* i  : ouput sampling rate                     */
);




ivas_error ivas_crend_init_from_rom(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder structure                  */
);
+5 −46
Original line number Diff line number Diff line
@@ -674,51 +674,6 @@ ivas_error dealloc_HRTF_binary(
}


/*-------------------------------------------------------------------------
 * ivas_hrtf_init()
 *
 * Initialize hHRTF handle
 *------------------------------------------------------------------------*/

static ivas_error ivas_hrtf_init(
    HRTFS_DATA *hHRTF /* i/o: HRTF handle     */
)
{
    int16_t i, j;

    if ( hHRTF == NULL )
    {
        return IVAS_ERR_WRONG_PARAMS;
    }

    hHRTF->latency_s = 0;
    hHRTF->max_num_ir = 0;
    hHRTF->max_num_iterations = 0;
    hHRTF->index_frequency_max_diffuse = 0;

    for ( i = 0; i < MAX_INTERN_CHANNELS; i++ )
    {
        hHRTF->inv_diffuse_weight[i] = 0;
        for ( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            hHRTF->num_iterations[i][j] = 0;
            hHRTF->pIndex_frequency_max[i][j] = NULL;
            hHRTF->pOut_to_bin_re[i][j] = NULL;
            hHRTF->pOut_to_bin_im[i][j] = NULL;
        }
    }
    for ( j = 0; j < BINAURAL_CHANNELS; j++ )
    {
        hHRTF->num_iterations_diffuse[j] = 0;
        hHRTF->pIndex_frequency_max_diffuse[j] = NULL;
        hHRTF->pOut_to_bin_diffuse_re[j] = NULL;
        hHRTF->pOut_to_bin_diffuse_im[j] = NULL;
    }

    return IVAS_ERR_OK;
}


/*---------------------------------------------------------------------*
 * create_HRTF_from_rawdata()
 *
@@ -736,6 +691,7 @@ static ivas_error create_HRTF_from_rawdata(
    uint32_t mem_size;
    char *hrtf_data_rptr;
    float *pOut_to_bin_wptr;
    ivas_error error;

    if ( *hHRTF == NULL )
    {
@@ -744,7 +700,10 @@ static ivas_error create_HRTF_from_rawdata(
            return IVAS_ERROR( IVAS_ERR_UNEXPECTED_NULL_POINTER, "Can not allocate memory for HRTF binary data\n" );
        }

        ivas_hrtf_init( *hHRTF );
        if ( ( error = ivas_hrtf_init( *hHRTF ) ) != IVAS_ERR_OK )
        {
            return error;
        }
    }
    else
    {