Commit 4be8e5b8 authored by Arthur Tritthart's avatar Arthur Tritthart
Browse files

added lookup s27

parent cd62c458
Loading
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ 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;
@@ -266,6 +267,41 @@ static Word16 ari_lookup_s27_fx(
    }

    return il;
#else

    const UWord16 *p = cum_freq;

    if ( L_msui_32_16( cum, range, p[11] ) < 0 )
    {
        p = p + 11;
        move16();
    }
    if ( L_msui_32_16( cum, range, p[8] ) < 0 )
    {
        p = p + 8;
        move16();
    }
    if ( L_msui_32_16( cum, range, p[4] ) < 0 )
    {
        p = p + 4;
        move16();
    }
    if ( L_msui_32_16( cum, range, p[2] ) < 0 )
    {
        p = p + 2;
        move16();
    }
    if ( L_msui_32_16( cum, range, p[1] ) < 0 )
    {
        p = p + 1;
        move16();
    }

    /* return extract_l(L_shr(L_sub((Word32)p,(Word32)cum_freq),1)); */
    L_sub( 0, 0 );
    L_shr( 0, 0 ); /* pointer subtraction */
    return extract_l( p - cum_freq );
#endif
}

static Word16 ari_lookup_bit_fx(
@@ -396,7 +432,9 @@ 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;
@@ -404,8 +442,10 @@ 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();
@@ -414,7 +454,11 @@ 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();
@@ -429,7 +473,11 @@ 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();
@@ -445,7 +493,11 @@ 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();