Commit f68cfdcc authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'float_code_cleanup_encoder_paths_ltv_crash_fixes' into 'main'

Encoder paths float code cleanup, LTV crash fixes, Q-info updates for lib_com files

See merge request !778
parents 0c981e1d d3befffa
Loading
Loading
Loading
Loading
Loading
+12 −25
Original line number Diff line number Diff line
@@ -1829,54 +1829,43 @@ ivas_error openCldfb_ivas(
ivas_error openCldfb_ivas_enc(
    HANDLE_CLDFB_FILTER_BANK *h_cldfb, /* i/o: filter bank handle                */
    CLDFB_TYPE type,                   /* i  : analysis or synthesis             */
    const int32_t sampling_rate,       /* i  : sampling rate                     */
    const Word32 sampling_rate,        /* i  : sampling rate                     */
    CLDFB_PROTOTYPE prototype          /* i  : CLDFB version (1.25ms/5ms delay)  */
)
{
    HANDLE_CLDFB_FILTER_BANK hs;
    int16_t buf_len;
    Word16 buf_len;

    if ( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
    IF( ( hs = (HANDLE_CLDFB_FILTER_BANK) malloc( sizeof( CLDFB_FILTER_BANK ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }

    hs->type = type;
    move32();
    hs->prototype = prototype;
    move32();

#ifndef IVAS_FLOAT_FIXED
    configureCldfb_ivas_enc( hs, sampling_rate );
    hs->memory_flt = NULL;
#else
    configureCldfb_ivas_enc_fx( hs, sampling_rate );
#endif
    hs->memory_length = 0;
    move32();

    if ( type == CLDFB_ANALYSIS )
    IF( type == CLDFB_ANALYSIS )
    {
        buf_len = hs->p_filter_length - hs->no_channels;
#ifdef IVAS_FLOAT_FIXED
        buf_len = sub( hs->p_filter_length, hs->no_channels );
        hs->FilterStates = (Word16 *) malloc( ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
#endif
        move16();
    }
    else
    ELSE
    {
        buf_len = hs->p_filter_length;
#ifdef IVAS_FLOAT_FIXED
        move16();
        hs->FilterStates = (Word16 *) malloc( 2 * ( 9 + 16 ) * CLDFB_getNumChannels( sampling_rate ) * sizeof( Word16 ) );
        hs->FilterStates_eg = 0;
#endif
        move16();
    }

#ifndef IVAS_FLOAT_FIXED
    if ( ( hs->cldfb_state = (float *) malloc( buf_len * sizeof( float ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
    }
    set_f( hs->cldfb_state, 0.0f, buf_len );
#endif
#ifdef IVAS_FLOAT_FIXED
    if ( ( hs->cldfb_state_fx = (Word32 *) malloc( buf_len * sizeof( Word32 ) ) ) == NULL )
    {
        return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" );
@@ -1890,8 +1879,6 @@ ivas_error openCldfb_ivas_enc(
    move16();
    set16_fx( hs->FilterStates, 0, i_mult( 9 + 16, hs->no_channels ) );
    set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) );
#endif // IVAS_FLOAT_FIXED


    *h_cldfb = hs;

+4 −4
Original line number Diff line number Diff line
@@ -175,8 +175,10 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale )
    assert( 2048 /*1.0/(1<<4) Q15*/ < mult( scale, scale ) );
    /* Exponent invScalingFactor: -16 = -(2*7 (scale) + 2 (8.0) */
    hFdCngCom->invScalingFactor = shl( mult( scale, scale ), 1 );
    move16();
    /* Exponent scalingFactor: -15 = -(2*7 (scale) + 2 (8.0) - 1 (1.0)) */
    hFdCngCom->scalingFactor = div_s( 0x4000, hFdCngCom->invScalingFactor );
    move16();

    /* Initialize the overlap-add */
    set16_fx( hFdCngCom->timeDomainBuffer, 0, L_FRAME16k );
@@ -185,10 +187,8 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale )
    set16_fx( hFdCngCom->olapBufferAna_fx, 0, FFTLEN );
#endif // IVAS_FLOAT_FIXED

    move16();
    set16_fx( hFdCngCom->olapBufferSynth, 0, FFTLEN );
    hFdCngCom->olapBufferSynth2 = NULL;
    move16();

    /* Initialize the comfort noise generation */
    set32_fx( hFdCngCom->fftBuffer, 0, FFTLEN );
@@ -228,9 +228,9 @@ void initFdCngCom( HANDLE_FD_CNG_COM hFdCngCom, Word16 scale )
    hFdCngCom->seed = 0;
    move16();
    // hFdCngCom->seed2 = 1;
    move16();
    // move16();
    // hFdCngCom->seed3 = 2;
    move16();
    // move16();
    hFdCngCom->CngBitrate = -1;
    move16();

+7 −7
Original line number Diff line number Diff line
@@ -376,16 +376,16 @@ void pre_echo_att_ivas_fx(
        /*-------------------------------------------------------*
         * In normal cases, just compute the energy of the frame
         *-------------------------------------------------------*/
        Word16 exp_etmp = sub( 15, Q_new );
        etmp_fx = sum2_16_exp_fx( exc_fx, L_frame, &exp_etmp, 7 ); /* Q = 31-exp_etmp */

        etmp_fx = sum2_fx( exc_fx, L_frame ); /*2*Q_new+1 */

        etmp_fx = L_shr( etmp_fx, add( 8 + 1 - 4, shl( Q_new, 1 ) ) ); /*2*Q_new+1 //INV_L_FRAME = 1/256 -> Q4*/
        etmp_fx = L_shr( etmp_fx, 8 ); /*31-exp_etmp//INV_L_FRAME = 1/256*/

        if ( EQ_16( L_frame, L_FRAME16k ) )
        IF( EQ_16( L_frame, L_FRAME16k ) )
        {
            etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*2*Q_new+1*/
            etmp_fx = Mpy_32_16_1( etmp_fx, 26214 /* 0.8 in Q15 */ ); /*31 - exp_etmp*/
        }
        *Last_frame_ener_fx = etmp_fx;
        *Last_frame_ener_fx = L_shl( etmp_fx, sub( shl( Q_new, 1 ), sub( 30 /*31-1*/, exp_etmp ) ) ); /*2*Q_new+1*/
        move32();                                                                                     /*2*Q_new+1*/
    }

+108 −108

File changed.

Preview size limit exceeded, changes collapsed.

+30 −29

File changed.

Preview size limit exceeded, changes collapsed.

Loading