Commit 6e69ac15 authored by Jan Kiene's avatar Jan Kiene
Browse files

Accept FIX_2402_SIMPLIFY_ARI_CODEC

parent 0c59e09c
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -9,26 +9,6 @@
#include "cnst.h"


#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
/**
 * \brief  31x16 Bit multiply (x*y)
 *
 * \param[i] xh  high part, bit [30..15]
 * \param[i] xl  low part, 15 LSBits
 * \param[i] y
 *
 * \return x*y
 */
Word32 L_multi31x16_X2( Word16 xh, Word16 xl, Word16 y )
{
    Word32 z;

    z = L_shl( L_mult0( xh, y ), 15 );
    z = L_mac0( z, xl, y );

    return z;
}
#endif

/*---------------------------------------------------------------
  Ari 14 bits common routines
+0 −1
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@
#define NONBE_FIX_ISSUE_2206_AVOID_OVERFLOW_MSVQ_Interpol_Tran_fx /* FhG: Fix saturation crash in MSVQ_Interpol_Tran_fx() */
#define NONBE_FIX_ISSUE_2206_SWB_EXPERIMENT_FIX_2527    /* Fix crash from issue #2527 */
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* VA/Nokia: reintroduce format switching for g192 bitstreams */
#define FIX_2402_SIMPLIFY_ARI_CODEC                     /* FhG: basop issue 2402: simplified arithmetic in TCX arithmetic coder */
#define FIX_2402_REPL_EVS_ARI_CODEC_ENC                 /* FhG: basop issue 2402: replace EVS arith encoder with IVAS arith encoder */
#define FIX_BASOP_2551_HARM_SCALAR_QUAN                 /* FhG: issue 2551: Harmonize function pair tcx_scalar_quantization_fx*/
#define HARMONIZE_2564_GetEnergyCldfb                   /* FhG: harmonize GetEnergyCldfb derivates for evs/ivas  */
+0 −6
Original line number Diff line number Diff line
@@ -5050,12 +5050,6 @@ Word16 IGFCommonFuncsIGFGetCFTables_fx(
    const Word16 **cf_off_se11  /* o  : offsets for CF tables above         */
);

#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
Word32 L_multi31x16_X2(
    Word16 xh,
    Word16 xl,
    Word16 y );
#endif

#ifndef FIX_2402_INLINE_FCT_ARI_CODEC
Word32 mul_sbc_14bits(
+0 −184
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
 * Ari decode 14 bits routines
  -------------------------------------------------------------*/

#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
static Word32 L_msui_32_16( Word32 cum, Word32 range, Word16 cum_freq )
{
    /* WMOPS counting is done using L_sub, similar to other MSU operations */
@@ -21,15 +20,10 @@ static Word32 L_msui_32_16( Word32 cum, Word32 range, Word16 cum_freq )
    /* Note: No overflow or saturation feature required.                   */
    return L_sub( cum, range * cum_freq );
}
#endif

Word32 ari_decode_overflow_fx( Tastat *s )
{
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    return ( L_sub( s->high, s->low ) <= 0 );
#else
    return ( L_sub( L_sub( s->high, 1 ), s->low ) <= 0 );
#endif
}

/**
@@ -92,10 +86,6 @@ static Word16 ari_lookup_s17_fx(
)
{
    const UWord16 *p;
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
    Word32 tmp;
    Word16 range_l, range_h;
#endif

    p = cum_freq;

@@ -104,42 +94,6 @@ static Word16 ari_lookup_s17_fx(
    /*    tmp_p = p+8; if (tmp_p[0]*range>cum) p = tmp_p;                                                             */

    /* max value in p[x] is 16384 => 14 bits */
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
    range_l = extract_l( L_and( range, 0x7FFF ) );
    range_h = extract_l( L_shr( range, 15 ) );

    tmp = L_multi31x16_X2( range_h, range_l, p[8] );
    IF( GT_32( tmp, cum ) )
    {
        p = p + 8;
    }

    tmp = L_multi31x16_X2( range_h, range_l, p[4] );
    IF( GT_32( tmp, cum ) )
    {
        p = p + 4;
    }


    tmp = L_multi31x16_X2( range_h, range_l, p[2] );
    IF( GT_32( tmp, cum ) )
    {
        p = p + 2;
    }

    tmp = L_multi31x16_X2( range_h, range_l, p[1] );
    IF( GT_32( tmp, cum ) )
    {
        p = p + 1;

        tmp = L_multi31x16_X2( range_h, range_l, p[1] );
        test();
        IF( EQ_32( (Word32) ( &cum_freq[15] - p ), 0 ) && ( GT_32( tmp, cum ) ) )
        {
            p = p + 1;
        }
    }
#else
    if ( L_msui_32_16( cum, range, p[8] ) < 0 )
    {
        p = p + 8;
@@ -165,7 +119,6 @@ static Word16 ari_lookup_s17_fx(
            move16();
        }
    }
#endif

    /* return extract_l(L_shr(L_sub((Word32)p,(Word32)cum_freq),1)); */
    L_sub( 0, 0 );
@@ -179,99 +132,6 @@ static Word16 ari_lookup_s27_fx(
    UWord16 const *cum_freq /* Q0 */
)
{
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
    Word32 tmp;
    Word16 range_l, range_h;
    Word16 il, ih, im;

    /* Note: For each indirect addressing p[i], we assume a tmp pointer init followed by a costfree reading the value */
    /* If the value multiplied by range is greater than cum, the pointer p is set to the tmp pointer                  */
    /*    tmp_p = p+8; if (tmp_p[0]*range>cum) p = tmp_p;                                                             */

    /* max value in p[x] is 16384 => 14 bits */
    range_l = extract_l( L_and( range, 0x7FFF ) );
    range_h = extract_l( L_shr( range, 15 ) );

    /* begin change when compared with ari_decode_14bits_s17_ext_fx,
       starting with line: tmp = L_multi31x16_X2(range_h, range_l, p[8]); */
    il = 0;
    move16();
    ih = 27;
    move16();

    /* do a five step binary search, using the interval [il, ih) */
    im = 13;
    move16(); /* (il + ih) >> 1 */
    tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] );
    tmp = L_sub( tmp, cum );
    if ( ( tmp > 0 ) )
    {
        il = im;
        move16();
    }
    if ( ( tmp <= 0 ) )
    {
        ih = im;
        move16();
    }

    im = shr( add( il, ih ), 1 );
    tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] );
    tmp = L_sub( tmp, cum );
    if ( tmp > 0 )
    {
        il = im;
        move16();
    }
    if ( tmp <= 0 )
    {
        ih = im;
        move16();
    }

    im = shr( add( il, ih ), 1 );
    tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] );
    tmp = L_sub( tmp, cum );
    if ( tmp > 0 )
    {
        il = im;
        move16();
    }
    if ( tmp <= 0 )
    {
        ih = im;
        move16();
    }

    im = shr( add( il, ih ), 1 );
    tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] );
    tmp = L_sub( tmp, cum );
    if ( tmp > 0 )
    {
        il = im;
        move16();
    }
    if ( tmp <= 0 )
    {
        ih = im;
        move16();
    }

    IF( GT_16( sub( ih, il ), 1 ) ) /* if the interval has more than one symbol */
    {
        /* here, only ih == il + 2 is possible, which means two symbols in the interval */
        im = add( il, 1 ); /* (il + ih) >> 1 */
        tmp = L_multi31x16_X2( range_h, range_l, cum_freq[im] );
        tmp = L_sub( tmp, cum );
        if ( tmp > 0 )
        {
            il = im;
            move16();
        }
    }

    return il;
#else

    const UWord16 *p = cum_freq;

@@ -305,7 +165,6 @@ static Word16 ari_lookup_s27_fx(
    L_sub( 0, 0 );
    L_shr( 0, 0 ); /* pointer subtraction */
    return extract_l( p - cum_freq );
#endif
}

static Word16 ari_lookup_bit_fx(
@@ -319,26 +178,10 @@ static Word16 ari_lookup_bit_fx(

    (void) cum_freq;

#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
    range = L_shl( range, 13 ); /* L_multi31x16_X2(range_h, range_l, 8192) */
    cum = L_sub( range, cum );

    if ( cum > 0 )
    {
        symbol = 1;
        move16();
    }
    if ( cum <= 0 )
    {
        symbol = 0;
        move16();
    }
#else
    if ( L_msui_32_16( cum, range, 8192 ) < 0 )
    {
        symbol = add( symbol, 1 ); /* symbol = 1 */
    }
#endif
    return symbol;
}

@@ -366,15 +209,7 @@ static Word16 ari_decode_14bits_ext_fx(
    range = L_sub( high, low );

    cum = L_add( L_shl( L_sub( value, low ), stat_bitsnew ), sub( shl( 1, stat_bitsnew ), 1 ) );
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
    if ( cum < 0 )
    {
        cum = 0x7fffffff;
        move32();
    }
#else
    assert( cum >= 0 );
#endif

    symbol = lookup_fn( cum, range, cum_freq );

@@ -446,9 +281,6 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
{
    Word32 cum, range;
    Word16 symbol;
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
    Word16 range_h, range_l;
#endif
    Word16 pows[12]; /* "base" to the power of 2, 4, 8,... 2^12 */
    Word16 lowlim, highlim, testval;
    Word16 k;
@@ -456,10 +288,6 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
    range = L_sub( s->high, s->low );
    cum = L_add( L_shl( L_sub( s->value, s->low ), stat_bitsnew ), ( ( 1 << stat_bitsnew ) - 1 ) );

#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
    range_h = extract_l( L_shr( range, 15 ) );
    range_l = extract_l( L_and( range, 0x7FFF ) );
#endif

    symbol = 0;
    move16();
@@ -468,11 +296,7 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
    move16();

    /* search for the interval where "cum" fits */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    IF( L_msui_32_16( cum, range, lowlim ) < 0 ) /* below pow-1 */
#else
    IF( GT_32( L_multi31x16_X2( range_h, range_l, lowlim ), cum ) ) /* below pow-1 */
#endif
    {
        pows[0] = base;
        move16();
@@ -487,11 +311,7 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
            move16();
            testval = mult_r( pows[k], base );

#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            IF( L_msui_32_16( cum, range, shr( testval, 1 ) ) >= 0 )
#else
            IF( LE_32( L_multi31x16_X2( range_h, range_l, shr( testval, 1 ) ), cum ) ) /* found! big range is [lowlim,testval], (now narrow it down) */
#endif
            {
                lowlim = testval;
                move16();
@@ -507,11 +327,7 @@ static Word16 ari_lookup_pow_fx( Tastat *s, Word16 base )
        {
            testval = mult_r( highlim, pows[k + 1] );

#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            IF( L_msui_32_16( cum, range, shr( testval, 1 ) ) >= 0 )
#else
            IF( LE_32( L_multi31x16_X2( range_h, range_l, shr( testval, 1 ) ), cum ) )
#endif
            {
                lowlim = testval;
                move16();