Commit d2bf6c24 authored by vaclav's avatar vaclav
Browse files

fix to hrtf memory deallocation

parent 35e474a5
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -807,7 +807,9 @@ 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 );
    }

@@ -3711,11 +3713,13 @@ static ivas_error IVAS_DEC_LoadHrtfFromFile(
            destroy_td_hrtf( hHrtfBinary->hHrtfTD );
        }

#ifndef FIX_1227_Crend_HRTF_LOADING_OPTIM
        if ( !( binaural_renderer == IVAS_BIN_RENDERER_TYPE_CREND || binaural_renderer == IVAS_BIN_RENDERER_TYPE_DEFAULT ) && hHrtfBinary->hSetOfHRTF != NULL )
        {
            destroy_SetOfHRTF( hHrtfBinary->hSetOfHRTF );
        }

#endif
        if ( ( error = IVAS_DEC_HRTF_binary_close( hIvasDec, hHrtfBinary->binaural_renderer_old ) ) != IVAS_ERR_OK )
        {
            return error;
+24 −17
Original line number Diff line number Diff line
@@ -203,10 +203,6 @@ static ivas_error ivas_rend_initCrend(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Encountered unsupported output type in Crend" );
    }

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    pCrend->hrtf_handle_reuse_flag = 0;

#endif
    if ( hHrtf == NULL )
    {
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
@@ -236,9 +232,6 @@ static ivas_error ivas_rend_initCrend(
            }
#endif

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
            pCrend->hrtf_handle_reuse_flag = 1;
#endif
            hHrtf->init_from_rom = 0;
        }
        else
@@ -926,9 +919,30 @@ static ivas_error ivas_rend_initCrend(
#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];

                    if ( ext_rend_flag == 0 )
                    {
                        /* in case of HRTF handle reuse, swap the pointers for correct deallocation at the exit */
                        const uint16_t *p_tmp;
                        p_tmp = hHrtf->pIndex_frequency_max[i][j];
                        hHrtf->pIndex_frequency_max[i][j] = hHrtf->pIndex_frequency_max[tmp][j];
                        hHrtf->pIndex_frequency_max[tmp][j] = p_tmp;

                        const float *p_tmpF;
                        p_tmpF = hHrtf->pOut_to_bin_re[i][j];
                        hHrtf->pOut_to_bin_re[i][j] = hHrtf->pOut_to_bin_re[tmp][j];
                        hHrtf->pOut_to_bin_re[tmp][j] = p_tmpF;

                        p_tmpF = hHrtf->pOut_to_bin_im[i][j];
                        hHrtf->pOut_to_bin_im[i][j] = hHrtf->pOut_to_bin_im[tmp][j];
                        hHrtf->pOut_to_bin_im[tmp][j] = p_tmpF;
                    }
                    else
                    {
                        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 )
                    {
@@ -1337,9 +1351,6 @@ ivas_error ivas_rend_initCrendWrapper(

    ( *pCrend )->binaural_latency_ns = 0;
    ( *pCrend )->hHrtfCrend = NULL;
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    ( *pCrend )->hrtf_handle_reuse_flag = 0;
#endif

    for ( pos_idx = 0; pos_idx < num_poses; pos_idx++ )
    {
@@ -1627,11 +1638,7 @@ void ivas_rend_closeCrend(
        return;
    }

#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    if ( ( *pCrend )->hrtf_handle_reuse_flag == 0 && ( *pCrend )->hHrtfCrend != NULL )
#else
    if ( ( *pCrend )->hHrtfCrend != NULL )
#endif
    {
        ivas_hrtf_close( &( *pCrend )->hHrtfCrend );
    }
+0 −3
Original line number Diff line number Diff line
@@ -1210,9 +1210,6 @@ typedef struct ivas_binaural_crend_wrapper_struct
    int32_t binaural_latency_ns;
    CREND_HANDLE hCrend[MAX_HEAD_ROT_POSES];
    HRTFS_HANDLE hHrtfCrend;
#ifdef FIX_1227_Crend_HRTF_LOADING_OPTIM
    int16_t hrtf_handle_reuse_flag;
#endif

} CREND_WRAPPER, *CREND_WRAPPER_HANDLE;