Commit 2c7a0d77 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

ivas dirac dec rend functions conversion, efap and reverb cleanup

[x] Converted ivas_dirac_dec_output_synthesis_process_subframe_psd_ls() and it's subfunctions
[x] getEfapGains_fx integrated
[x] ivas reverb cleanup and basop changes
[x] Fix for High MLD issues for [SBA at 48 kbps, 32kHz in, 32kHz out, BINAURAL ROOM IR out, HR, reference vector tracking, in level exo]
parent c15b61e2
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2717,7 +2717,7 @@ enum
#define LG10                                  24660       /*  10*log10(2)  in Q13                 */
#define LG10_s3_0                             16440       /* 10*log10(2)/1.55 = 1.00343331 in Q14              */
#define LOG2_10                               27213      /* log base 2 of 10 in Q12 */
#define INV_LOG10_2_Q31                       646456993      /* inverse log base 10 of 2 in Q31 */
#define LOG10_2_Q31                           646456993      /* inverse log base 10 of 2 in Q31 */
#define MU_MA_FX                              10923     /* original prediction factor for the AMR WB tables (Q15) */

#define E_MIN_FXQ15                           115     /* Q15*/
+41 −0
Original line number Diff line number Diff line
@@ -248,6 +248,47 @@ Word16 L_get_q_buf( float *ptr_flt, Word16 length )
        return sub( norm_l( (Word32) ftemp ), 0 );
    }
}

Word16 L_get_q1( float f )
{
    if ( fabsf( f ) >= 0.f && fabsf( f ) < 1.f )
    {
        return Q31;
    }
    else if ( fabsf( f ) > (float) INT_MAX )
    {
        return sub( sub( W_norm( (Word64) f ), 32 ), 0 );
    }
    else
    {
        return sub( norm_l( (Word32) f ), 0 );
    }
}

Word16 L_get_q_buf1( float *ptr_flt, Word16 length )
{
    Word16 k;
    float ftemp = 0.0;

    for ( k = 0; k < length; k++ )
    {
        if ( fabsf( ptr_flt[k] ) > ftemp )
            ftemp = fabsf( ptr_flt[k] );
    }

    if ( ftemp >= 0.f && ftemp < 1.f )
    {
        return Q31;
    }
    else if ( ftemp > (float) INT_MAX )
    {
        return sub( sub( W_norm( (Word64) ftemp ), 32 ), 0 );
    }
    else
    {
        return sub( norm_l( (Word32) ftemp ), 0 );
    }
}
#endif

#ifdef IVAS_FLOAT_FIXED
+2 −0
Original line number Diff line number Diff line
@@ -132,8 +132,10 @@ void fix2f(Word32 *var_fix, float *var_flt, Word32 expo);
#ifdef IVAS_FLOAT_FIXED
// Get max Q factor for a float value before sat in 32-bit
Word16 L_get_q( float f );
Word16 L_get_q1( float f );
// Get max Q factor for a float buffer before sat in 32-bit
Word16 L_get_q_buf( float *ptr_flt, Word16 length );
Word16 L_get_q_buf1( float *ptr_flt, Word16 length );
#endif

Word32 Mult_32_16(
+2 −2
Original line number Diff line number Diff line
@@ -3662,8 +3662,8 @@ void decoder_tcx_ivas_fx(
    Scale_sig( st->hTcxDec->syn_Overl_TDACFB, 480, -( st->Q_syn + 2 ) );              // Scaling to Q-2
    Scale_sig( st->hTcxDec->syn_OverlFB, 480, -( st->Q_syn + 2 ) );                   // Scaling to Q-2
    Scale_sig( st->hTcxDec->old_syn_Overl, 320, -( st->Q_syn + 1 + 0 ) );             // Scaling to Q-2
    Scale_sig( st->hHQ_core->old_out_LB_fx, 640, -( st->hHQ_core->Q_old_wtda + 2 ) ); // Scaling to Q-2
    Scale_sig( st->hHQ_core->old_out_fx, 960, -( st->hHQ_core->Q_old_wtda + 2 ) );    // Scaling to Q-2
    Scale_sig( st->hHQ_core->old_out_LB_fx, 640, -( st->Q_syn + 2 ) ); // Scaling to Q-2
    Scale_sig( st->hHQ_core->old_out_fx, 960, -( st->Q_syn + 2 ) );    // Scaling to Q-2

    Copy_Scale_sig_16_32_no_sat( st->old_Aq_12_8_fx, st->old_Aq_12_8_fx_32, M + 1, ( 28 - ( 15 - norm_s( st->old_Aq_12_8_fx[0] - 1 ) ) ) );

+116 −1
Original line number Diff line number Diff line
@@ -1211,7 +1211,7 @@ ivas_error ivas_allocate_binaural_hrtf(
 *
 *
 *-------------------------------------------------------------------------*/

#ifdef IVAS_FLOAT_FIXED
static ivas_error ivas_binaural_hrtf_open(
    HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i  : fastconv HRTF handle */
    const AUDIO_CONFIG input_config,      /* i  : output configuration */
@@ -1326,7 +1326,122 @@ static ivas_error ivas_binaural_hrtf_open(

    return IVAS_ERR_OK;
}
#else
static ivas_error ivas_binaural_hrtf_open(
    HRTFS_FASTCONV_HANDLE *hHrtfFastConv, /* i  : fastconv HRTF handle */
    const AUDIO_CONFIG input_config,      /* i  : output configuration */
    const RENDERER_TYPE renderer_type     /* i  : renderer type        */
)
{
    int16_t i, j;
    ivas_error error;

    if ( hHrtfFastConv != NULL && *hHrtfFastConv != NULL )
    {
        /* Tables already loaded from file */
        return IVAS_ERR_OK;
    }
    else
    {
        /* Initialise tables from ROM */
        HRTFS_FASTCONV *HrtfFastConv;

        if ( ( HrtfFastConv = (HRTFS_FASTCONV *) malloc( sizeof( HRTFS_FASTCONV ) ) ) == NULL )
        {
            return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Could not allocate memory for FastConv HRTF tables" );
        }

        ivas_init_binaural_hrtf( HrtfFastConv );

        if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV )
        {
            HrtfFastConv->FASTCONV_HRIR_latency_s = FASTCONV_HRIR_latency_s;
        }
        if ( input_config == IVAS_AUDIO_CONFIG_HOA2 )
        {
            HrtfFastConv->FASTCONV_HOA2_latency_s = FASTCONV_HOA2_latency_s;
        }
        if ( input_config == IVAS_AUDIO_CONFIG_HOA3 )
        {
            HrtfFastConv->FASTCONV_HOA3_latency_s = FASTCONV_HOA3_latency_s;
        }
        if ( input_config == IVAS_AUDIO_CONFIG_FOA )
        {
            HrtfFastConv->FASTCONV_FOA_latency_s = FASTCONV_FOA_latency_s;
        }
        if ( input_config == IVAS_AUDIO_CONFIG_BINAURAL || renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
        {
            HrtfFastConv->FASTCONV_BRIR_latency_s = FASTCONV_BRIR_latency_s;
        }

        HrtfFastConv->allocate_init_flag = 1;

        if ( ( error = ivas_allocate_binaural_hrtf( HrtfFastConv, input_config, BINAURAL_INPUT_AUDIO_CONFIG_INVALID, renderer_type, HrtfFastConv->allocate_init_flag ) ) != IVAS_ERR_OK )
        {
            return error;
        }
        for ( i = 0; i < BINAURAL_CONVBANDS; i++ )
        {
            if ( renderer_type == RENDERER_BINAURAL_FASTCONV )
            {
                for ( j = 0; j < HRTF_LS_CHANNELS; j++ )
                {
                    HrtfFastConv->leftHRIRReal[i][j] = leftHRIRReal[i][j];
                    HrtfFastConv->leftHRIRImag[i][j] = leftHRIRImag[i][j];
                    HrtfFastConv->rightHRIRReal[i][j] = rightHRIRReal[i][j];
                    HrtfFastConv->rightHRIRImag[i][j] = rightHRIRImag[i][j];
                }
            }
            else if ( renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
            {
                for ( j = 0; j < HRTF_LS_CHANNELS; j++ )
                {
                    HrtfFastConv->leftBRIRReal[i][j] = leftBRIRReal[i][j];
                    HrtfFastConv->leftBRIRImag[i][j] = leftBRIRImag[i][j];
                    HrtfFastConv->rightBRIRReal[i][j] = rightBRIRReal[i][j];
                    HrtfFastConv->rightBRIRImag[i][j] = rightBRIRImag[i][j];
                }
            }
            if ( input_config == IVAS_AUDIO_CONFIG_HOA3 )
            {
                for ( j = 0; j < HOA3_CHANNELS; j++ )
                {
                    HrtfFastConv->leftHRIRReal_HOA3[i][j] = leftHRIRReal_HOA3[i][j];
                    HrtfFastConv->leftHRIRImag_HOA3[i][j] = leftHRIRImag_HOA3[i][j];
                    HrtfFastConv->rightHRIRReal_HOA3[i][j] = rightHRIRReal_HOA3[i][j];
                    HrtfFastConv->rightHRIRImag_HOA3[i][j] = rightHRIRImag_HOA3[i][j];
                }
            }
            if ( input_config == IVAS_AUDIO_CONFIG_HOA2 )
            {
                for ( j = 0; j < HOA2_CHANNELS; j++ )
                {
                    HrtfFastConv->leftHRIRReal_HOA2[i][j] = leftHRIRReal_HOA2[i][j];
                    HrtfFastConv->leftHRIRImag_HOA2[i][j] = leftHRIRImag_HOA2[i][j];
                    HrtfFastConv->rightHRIRReal_HOA2[i][j] = rightHRIRReal_HOA2[i][j];
                    HrtfFastConv->rightHRIRImag_HOA2[i][j] = rightHRIRImag_HOA2[i][j];
                }
            }
            if ( input_config == IVAS_AUDIO_CONFIG_FOA )
            {
                for ( j = 0; j < FOA_CHANNELS; j++ )
                {
                    HrtfFastConv->leftHRIRReal_FOA[i][j] = leftHRIRReal_FOA[i][j];
                    HrtfFastConv->leftHRIRImag_FOA[i][j] = leftHRIRImag_FOA[i][j];
                    HrtfFastConv->rightHRIRReal_FOA[i][j] = rightHRIRReal_FOA[i][j];
                    HrtfFastConv->rightHRIRImag_FOA[i][j] = rightHRIRImag_FOA[i][j];
                }
            }
        }
        mvr2r( fastconvReverberationTimes, HrtfFastConv->fastconvReverberationTimes, CLDFB_NO_CHANNELS_MAX );
        mvr2r( fastconvReverberationEneCorrections, HrtfFastConv->fastconvReverberationEneCorrections, CLDFB_NO_CHANNELS_MAX );

        *hHrtfFastConv = HrtfFastConv;
    }

    return IVAS_ERR_OK;
}
#endif
#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------------*
 * ivas_binaural_obtain_DMX()
Loading