Commit c2be5f1c authored by Arash Azizi's avatar Arash Azizi
Browse files

Merge branch 'main' into basop_issue_2653

# Conflicts:
#	lib_com/options.h
parents 8797a768 13edf320
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -23,7 +23,9 @@
#include "prot_fx.h"
#include <assert.h>

#ifndef HARMONIZE_2583_open_decoder_LPD
#define STATE_BUFFER_SIZE ( 9 + 16 )
#endif

#define CLDFB_NO_POLY       ( 5 )
#define SYN_FILTER_HEADROOM ( 1 )
@@ -1438,7 +1440,7 @@ static Word16 CLDFB_getNumChannels(
    return ( nChannels );
}


#ifndef HARMONIZE_2583_open_decoder_LPD
/*-------------------------------------------------------------------*
 * cldfb_get_memory_length()
 *
@@ -1457,6 +1459,7 @@ static Word16 cldfb_get_memory_length(
        return ( i_mult( hs->no_channels, ( 9 * 2 ) ) );
    }
}
#endif


/*-------------------------------------------------------------------*
+55 −0
Original line number Diff line number Diff line
@@ -1766,6 +1766,26 @@ static void cldfb_init_proto_and_twiddles(
    return;
}

#ifdef HARMONIZE_2583_open_decoder_LPD
/*-------------------------------------------------------------------*
 * cldfb_get_memory_length()
 *
 * Return length of filter state for recovery
 *--------------------------------------------------------------------*/

Word16 cldfb_get_memory_length(
    HANDLE_CLDFB_FILTER_BANK hs )
{
    IF( EQ_16( hs->type, CLDFB_ANALYSIS ) )
    {
        return ( i_mult( hs->no_channels, STATE_BUFFER_SIZE ) );
    }
    ELSE
    {
        return ( i_mult( hs->no_channels, ( 9 * 2 ) ) );
    }
}
#endif

/*-------------------------------------------------------------------*
 * cldfb_save_memory_ivas()
@@ -1864,6 +1884,7 @@ void cldfb_reset_memory_fx(
    Word16 memory_length;
    UWord16 offset = sub( hs->p_filter_length, hs->no_channels );

#ifndef HARMONIZE_2583_open_decoder_LPD
    IF( hs->type == CLDFB_ANALYSIS )
    {
        memory_length = offset;
@@ -1883,4 +1904,38 @@ void cldfb_reset_memory_fx(
    move16();

    return;
#else  /*HARMONIZE_2583_open_decoder_LPD*/

    IF( hs->FilterStates )
    {
        /*EVS part*/
        memory_length = cldfb_get_memory_length( hs );
        set16_fx( hs->FilterStates, 0, memory_length );
        set16_fx( hs->FilterStates_e, 0, sizeof( hs->FilterStates_e ) / sizeof( hs->FilterStates_e[0] ) );
        hs->FilterStates_eg = 0;
        move16();
    }
    ELSE
    {
        /*IVAS part*/
        IF( hs->type == CLDFB_ANALYSIS )
        {
            memory_length = offset;
            move16();
        }
        ELSE
        {
            memory_length = hs->p_filter_length;
            move16();
        }

        hs->cldfb_state_length = memory_length;
        move16();
        /* save the memory */
        set32_fx( hs->cldfb_state_fx, 0, memory_length );
        hs->Q_cldfb_state = Q11;
        move16();
    }
    return;
#endif /*HARMONIZE_2583_open_decoder_LPD*/
}
+3 −0
Original line number Diff line number Diff line
@@ -2610,6 +2610,9 @@ typedef enum SIGNAL_CLASSIFER_MODE
#define SCALE_CLDFB_SYN_40                      ( SCALE_MODULATION + SCALE_GAIN_SYN )
#define SCALE_CLDFB_SYN_60                      ( SCALE_MODULATION + SCALE_GAIN_SYN )
#define SCALE_CLDFB_SYN_30                      ( SCALE_MODULATION + SCALE_GAIN_SYN )
#ifdef HARMONIZE_2583_open_decoder_LPD
#define STATE_BUFFER_SIZE                       ( 9 + 16 )
#endif


/*----------------------------------------------------------------------------------*
+82 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ static UWord16 ivas_ari_get_symbol(
 *
 *-------------------------------------------------------------*/

#ifndef FIX_2402_SIGNED_VERSION
UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe(
    Decoder_State *st,
    Tastat *s,
@@ -180,6 +181,87 @@ UWord16 ivas_ari_decode_14bits_bit_ext_1_lfe(

    return symbol;
}
#else /* FIX_2402_SIGNED_VERSION */
Word16 ivas_ari_decode_14bits_bit_ext_1_lfe(
    Decoder_State *st,
    Tastat *s,
    const UWord16 *cum_freq,
    Word16 *extra_bits_read )
{
    Word16 symbol;
    Word32 low, high, range, value;
    Word32 cum;

    /* read s->low,high,value sequentially */
    low = s->low;
    high = s->high;
    value = s->value;

    move32();
    move32();
    move32();

    range = L_add( L_sub( high, low ), 1 );
    cum = L_sub( L_lshl( ( L_add( L_sub( value, low ), 1 ) ), stat_bitsnew ), 1 );

    symbol = ivas_ari_get_symbol( cum_freq, range, cum );

    high = L_sub( L_add( low, mul_sbc_14bits( range, cum_freq[symbol] ) ), 1 );
    low = L_add( low, mul_sbc_14bits( range, cum_freq[symbol + 1] ) );

    FOR( ;; )
    {
        IF( GE_32( high, ari_q2new ) )
        {
            IF( GE_32( low, ari_q2new ) )
            {
                value = L_sub( value, ari_q2new );
                low = L_sub( low, ari_q2new );
                high = L_sub( high, ari_q2new );
            }
            ELSE
            {
                test();
                IF( GE_32( low, ari_q1new ) && LT_32( high, ari_q3new ) )
                {
                    value = L_sub( value, ari_q1new );
                    low = L_sub( low, ari_q1new );
                    high = L_sub( high, ari_q1new );
                }
                ELSE
                {
                    BREAK;
                }
            }
        }

        low = L_add( low, low );
        high = L_add( high, UL_addNsD( high, 1 ) );

        IF( GE_16( st->next_bit_pos, st->bits_frame ) )
        {
            value = L_lshl( value, 1 );
            *extra_bits_read = add( *extra_bits_read, 1 );
            move16();
        }
        ELSE
        {
            value = L_or( L_lshl( value, 1 ), get_next_indice_1_fx( st ) );
        }
    }

    s->low = low;
    s->high = high;
    s->value = value;

    move32();
    move32();
    move32();

    return symbol;
}

#endif /* FIX_2402_SIGNED_VERSION */

/*---------------------------------------------------------------
 * Function ivas_ari_done_decoding_14bits_ext_1_lfe()
+5 −0
Original line number Diff line number Diff line
@@ -1165,7 +1165,12 @@ static Word16 ivas_calculate_abs_fr_fx(

    FOR( i = 0; i < frame_len; i++ )
    {
#ifdef FIX_BASOP_2642_INCORRECT_IF_THRESHOLD
        test();
        if ( LT_32( ppFilterbank_FRs_s_fx[i], 419430 ) )
#else
        if ( ppFilterbank_FRs_s_fx[i] < 0 )
#endif
        {
            ppFilterbank_FRs_s_fx[i] = 419430; // 0.1 in Q22
            move32();
Loading