Commit ac21387f authored by emerit's avatar emerit
Browse files

bugs fix

parent e8608679
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1474,7 +1474,7 @@ ivas_error ivas_binRenderer_open_fx(
        hBinRenderer->hoa_dec_mtx = st_ivas->hoa_dec_mtx;
#ifdef FIX_1123_FASTCONV_PARAMBIN_16BIT_ROM
#ifdef FIX_POINT_HRTF_FILE_OPTIM
        st_ivas->binaural_latency_ns = L_shr_r( Mult_32_32( st_ivas->hHrtfFastConv->FASTCONV_latency_s_fx, 1000000000 ), st_ivas->hHrtfFastConv->factor_Q_latency_s_fx );
        st_ivas->binaural_latency_ns = L_shr_r( Mult_32_32( st_ivas->hHrtfFastConv->FASTCONV_latency_s_fx, 1000000000 ), Q31 - st_ivas->hHrtfFastConv->factor_Q_latency_s_fx );
#else
        st_ivas->binaural_latency_ns = L_shr_r( Mult_32_32( st_ivas->hHrtfFastConv->FASTCONV_BRIR_latency_s_fx, 1000000000 ), st_ivas->hHrtfFastConv->factor_Q_latency_s_fx );
#endif
@@ -1496,7 +1496,7 @@ ivas_error ivas_binRenderer_open_fx(
        }

#ifdef FIX_1123_FASTCONV_PARAMBIN_16BIT_ROM
        st_ivas->binaural_latency_ns = L_shr_r( Mult_32_32( st_ivas->hHrtfFastConv->FASTCONV_latency_s_fx, 1000000000 ), st_ivas->hHrtfFastConv->factor_Q_latency_s_fx );
        st_ivas->binaural_latency_ns = L_shr_r( Mult_32_32( st_ivas->hHrtfFastConv->FASTCONV_latency_s_fx, 1000000000 ), Q31 - st_ivas->hHrtfFastConv->factor_Q_latency_s_fx );
#else
        IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) )
        {
+126 −77
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@

#ifdef FIX_POINT_HRTF_FILE_OPTIM
ivas_error ivas_Crend_hrtf_init(
    HRTFS_CREND_DATA *hHrtf_in, /* i/o: HRTF handle     */
    HRTFS_CREND_DATA *hHrtf     /* i/o: HRTF handle     */
)
#else
@@ -71,6 +72,8 @@ ivas_error ivas_hrtf_init(
        return IVAS_ERR_WRONG_PARAMS;
    }

    IF( hHrtf_in == NULL )
    {
        hHrtf->latency_s_fx = 0;
        hHrtf->gain_lfe_fx = 0;
        hHrtf->max_num_ir = 0;
@@ -113,7 +116,6 @@ ivas_error ivas_hrtf_init(
                hHrtf->pIndex_frequency_max_dyn[i][j] = NULL;
                hHrtf->pOut_to_bin_re_dyn_fx[i][j] = NULL;
                hHrtf->pOut_to_bin_im_dyn_fx[i][j] = NULL;

#endif
            }
        }
@@ -132,6 +134,71 @@ ivas_error ivas_hrtf_init(
            hHrtf->pOut_to_bin_diffuse_im_dyn_fx[j] = NULL;
#endif
        }
    }
    else
    {
        hHrtf->latency_s_fx = hHrtf_in->latency_s_fx;
        hHrtf->gain_lfe_fx = hHrtf_in->gain_lfe_fx;
        hHrtf->max_num_ir = hHrtf_in->max_num_ir;
        hHrtf->max_num_iterations = hHrtf_in->max_num_iterations;
        hHrtf->index_frequency_max_diffuse = hHrtf_in->index_frequency_max_diffuse;
        move32();
        move16();
        move16();
        move16();
        move16();
#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
        hHrtf->factor_Q_latency_s_fx = hHrtf_in->factor_Q_latency_s_fx;
        move16();
        hHrtf->factor_Q_inv_diffuse_weight = hHrtf_in->factor_Q_inv_diffuse_weight;
        move16();
        hHrtf->factor_Q_pOut_to_bin = hHrtf_in->factor_Q_pOut_to_bin;
        move16();
        hHrtf->same_inv_diffuse_weight = hHrtf_in->same_inv_diffuse_weight;
        move16();
#endif

        FOR( i = 0; i < MAX_INTERN_CHANNELS; i++ )
        {
#ifndef FIX_POINT_CREND_HRTF_FILE_FORMAT
            hHrtf->inv_diffuse_weight_fx[i] = hHrtf_in->inv_diffuse_weight_fx[i];
            move16();
#endif
            FOR( j = 0; j < BINAURAL_CHANNELS; j++ )
            {
#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
                hHrtf->inv_diffuse_weight_fx[j][i] = hHrtf_in->inv_diffuse_weight_fx[i][j];
                move16();
#endif
                hHrtf->num_iterations[i][j] = hHrtf_in->num_iterations[i][j];
                move16();
                hHrtf->pIndex_frequency_max[i][j] = hHrtf_in->pIndex_frequency_max[i][j];
                hHrtf->pOut_to_bin_re_fx[i][j] = hHrtf_in->pOut_to_bin_re_fx[i][j];
                hHrtf->pOut_to_bin_im_fx[i][j] = hHrtf_in->pOut_to_bin_im_fx[i][j];
#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
                hHrtf->pIndex_frequency_max_dyn[i][j] = hHrtf_in->pIndex_frequency_max_dyn[i][j];
                hHrtf->pOut_to_bin_re_dyn_fx[i][j] = hHrtf_in->pOut_to_bin_re_dyn_fx[i][j];
                hHrtf->pOut_to_bin_im_dyn_fx[i][j] = hHrtf_in->pOut_to_bin_im_dyn_fx[i][j];

#endif
            }
        }

        FOR( j = 0; j < BINAURAL_CHANNELS; j++ )
        {
            hHrtf->num_iterations_diffuse[j] = hHrtf_in->num_iterations_diffuse[j];
            move16();
            hHrtf->pIndex_frequency_max_diffuse[j] = hHrtf_in->pIndex_frequency_max_diffuse[j];

            hHrtf->pOut_to_bin_diffuse_re_fx[j] = hHrtf_in->pOut_to_bin_diffuse_re_fx[j];
            hHrtf->pOut_to_bin_diffuse_im_fx[j] = hHrtf_in->pOut_to_bin_diffuse_im_fx[j];
#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
            hHrtf->pIndex_frequency_max_diffuse_dyn[j] = hHrtf_in->pIndex_frequency_max_diffuse_dyn[j];
            hHrtf->pOut_to_bin_diffuse_re_dyn_fx[j] = hHrtf_in->pOut_to_bin_diffuse_re_dyn_fx[j];
            hHrtf->pOut_to_bin_diffuse_im_dyn_fx[j] = hHrtf_in->pOut_to_bin_diffuse_im_dyn_fx[j];
#endif
        }
    }

#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
    hHrtf->init_from_rom = 1;
@@ -146,6 +213,7 @@ ivas_error ivas_hrtf_init(
 * Open hHrtf handle
 *------------------------------------------------------------------------*/
static ivas_error ivas_hrtf_open(
    HRTFS_HANDLE hHrtf_in,
    HRTFS_HANDLE *hHrtf_out /* o  : HRTF handle     */
)
{
@@ -160,7 +228,7 @@ static ivas_error ivas_hrtf_open(
        }

#ifdef FIX_POINT_HRTF_FILE_OPTIM
        IF( NE_32( ( error = ivas_Crend_hrtf_init( hHrtf ) ), IVAS_ERR_OK ) )
        IF( NE_32( ( error = ivas_Crend_hrtf_init( hHrtf_in, hHrtf ) ), IVAS_ERR_OK ) )
#else
        IF( NE_32( ( error = ivas_hrtf_init( hHrtf ) ), IVAS_ERR_OK ) )
#endif
@@ -248,27 +316,20 @@ static ivas_error ivas_rend_initCrend_fx(
    IF( hHrtf == NULL )
    {
#ifdef FIX_POINT_HRTF_FILE_OPTIM
        IF( hHrtfCrend != NULL )
        {
            /* HRTF set loaded from binary file */
            hHrtf = hHrtfCrend;
            hHrtf->init_from_rom = 0;
        }
        ELSE
        {
        /* create new handle when HRTF is loaded from ROM, or external renderer is used */
            IF( NE_32( ( error = ivas_hrtf_open( &hHrtf ) ), IVAS_ERR_OK ) )
        IF( NE_32( ( error = ivas_hrtf_open( hHrtfCrend, &hHrtf ) ), IVAS_ERR_OK ) )
        {
            return error;
        }

            hHrtf->init_from_rom = 1;
        IF( hHrtfCrend != NULL )
        {
            hHrtf->init_from_rom = 0;
        }
            move16();
        ELSE
        {
            hHrtf->init_from_rom = 1;
        }
        move16();
#else
        IF( NE_32( ivas_hrtf_open( &hHrtf ), IVAS_ERR_OK ) )
        {
@@ -1135,18 +1196,6 @@ static ivas_error ivas_rend_initCrend_fx(
            }
        }
    }
    if ( hHrtf->factor_Q_latency_s_fx != 0 )
    {
        hHrtf->factor_Q_latency_s_fx = sub( 31, hHrtf->factor_Q_latency_s_fx );
    }
    if ( hHrtf->factor_Q_inv_diffuse_weight != 0 )
    {
        hHrtf->factor_Q_inv_diffuse_weight = sub( 15, hHrtf->factor_Q_inv_diffuse_weight );
    }
    if ( hHrtf->factor_Q_pOut_to_bin != 0 )
    {
        hHrtf->factor_Q_pOut_to_bin = sub( 15, hHrtf->factor_Q_pOut_to_bin );
    }
    pCrend->hHrtfCrend = hHrtf;

    return IVAS_ERR_OK;
@@ -2751,7 +2800,7 @@ ivas_error ivas_rend_openCrend(
            hCrend->hReverb = NULL;
        }
#ifdef FIX_POINT_CREND_HRTF_FILE_FORMAT
        ( *pCrend )->binaural_latency_ns = L_shr_r( Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, 1000000000 ), ( *pCrend )->hHrtfCrend->factor_Q_latency_s_fx );
        ( *pCrend )->binaural_latency_ns = L_shr_r( Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, 1000000000 ), Q31 - ( *pCrend )->hHrtfCrend->factor_Q_latency_s_fx );
#else
        ( *pCrend )->binaural_latency_ns = Mult_32_32( ( *pCrend )->hHrtfCrend->latency_s_fx, (Word32) 1000000000 );
#endif
@@ -3196,17 +3245,17 @@ static ivas_error ivas_rend_crendConvolver(
    {
        FOR( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ )
        {
            pFreq_buf2_re[k] = L_shl( pFreq_buf2_re[k], pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
            pFreq_buf2_im[k] = L_shl( pFreq_buf2_im[k], pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
            pFreq_buf2_re[k] = L_shl( pFreq_buf2_re[k], Q15 - pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
            pFreq_buf2_im[k] = L_shl( pFreq_buf2_im[k], Q15 - pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
        }
        IF( pCrend->hHrtfCrend->same_inv_diffuse_weight == 0 )
        {
            FOR( k = 0; k < pCrend->hHrtfCrend->index_frequency_max_diffuse; k++ )
            {
                pFreq_buf2_re[k] = L_shl( pFreq_buf2_re[k], pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
                pFreq_buf2_im[k] = L_shl( pFreq_buf2_im[k], pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
                pFreq_buf3_re[k] = L_shl( pFreq_buf3_re[k], pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
                pFreq_buf3_im[k] = L_shl( pFreq_buf3_im[k], pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
                pFreq_buf2_re[k] = L_shl( pFreq_buf2_re[k], Q15 - pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
                pFreq_buf2_im[k] = L_shl( pFreq_buf2_im[k], Q15 - pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
                pFreq_buf3_re[k] = L_shl( pFreq_buf3_re[k], Q15 - pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
                pFreq_buf3_im[k] = L_shl( pFreq_buf3_im[k], Q15 - pCrend->hHrtfCrend->factor_Q_inv_diffuse_weight );
            }
        }
    }
@@ -3277,7 +3326,7 @@ static ivas_error ivas_rend_crendConvolver(
        pFreq_buf_re = &pcm_out[j][L_mult0( i_ts, subframe_length )];
        FOR( k = 0; k < subframe_length; k++ )
        {
            pFreq_buf_re[k] = L_shl( L_add( pOut[k], hCrend->prev_out_buffer_fx[j][k] ), pCrend->hHrtfCrend->factor_Q_pOut_to_bin );
            pFreq_buf_re[k] = L_shl( L_add( pOut[k], hCrend->prev_out_buffer_fx[j][k] ), Q15 - pCrend->hHrtfCrend->factor_Q_pOut_to_bin );
            hCrend->prev_out_buffer_fx[j][k] = pOut[k + subframe_length];
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ ivas_error ivas_HRTF_CRend_binary_open_fx(
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend HRTFS Handle\n" );
    }

    if ( ( error = ivas_Crend_hrtf_init( *hHrtfCrend ) ) != IVAS_ERR_OK )
    if ( ( error = ivas_Crend_hrtf_init( NULL, *hHrtfCrend ) ) != IVAS_ERR_OK )
    {
        return error;
    }
+1 −1
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ ivas_error ivas_td_binaural_open_unwrap_fx(
    IF( NE_16( ivas_format, MASA_ISM_FORMAT ) && NE_16( ivas_format, SBA_ISM_FORMAT ) )
    {
#ifdef FIX_TDREND_HRTF_FILE_FORMAT
        *binaural_latency_ns = L_shr_r( Mult_32_32( ( *hBinRendererTd )->HrFiltSet_p->latency_s_fx, 1000000000 ), 31 - ( *hBinRendererTd )->HrFiltSet_p->factor_Q_latency_s_fx );
        *binaural_latency_ns = L_shr_r( Mult_32_32( ( *hBinRendererTd )->HrFiltSet_p->latency_s_fx, 1000000000 ), Q31 - ( *hBinRendererTd )->HrFiltSet_p->factor_Q_latency_s_fx );
#else
        *binaural_latency_ns = Mult_32_32( ( *hBinRendererTd )->HrFiltSet_p->latency_s_fx, 1000000000 /* 1000000000.f in Q0 */ );
#endif
+1 −0
Original line number Diff line number Diff line
@@ -1315,6 +1315,7 @@ void ivas_rend_closeCrend(

#ifdef FIX_POINT_HRTF_FILE_OPTIM
ivas_error ivas_Crend_hrtf_init(
    HRTFS_CREND_DATA *hHrtf_in, /* i/o: HRTF handle     */
    HRTFS_CREND_DATA *hHrtf /* i/o: HRTF handle     */
);
#else
Loading