Commit ac2bca67 authored by Arthur Tritthart's avatar Arthur Tritthart
Browse files

further simplifications, changed saturation oof cum by assert

parent 8cd5fdce
Loading
Loading
Loading
Loading
Loading

lib_dec/ari_dec_fx.c

100644 → 100755
+28 −2
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@
/*---------------------------------------------------------------
 * Ari decode 14 bits routines
  -------------------------------------------------------------*/
//#define DEBUG_ari_decode_14bits

#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
static Word32 L_msui_32_16( Word32 cum, Word32 range, Word16 cum_freq )
@@ -48,6 +49,10 @@ void ari_start_decoding_14bits_fx(
    move32();
    s->value = val;
    move32();

#ifdef DEBUG_ari_decode_14bits
printf("ari_start_decoding_14bits_fx: low=0x%08X  high=0x%08X  value=0x%08X\n", s->low, s->high, s->value);
#endif
}

Word16 ari_start_decoding_14bits_prm_fx(
@@ -79,6 +84,9 @@ Word16 ari_start_decoding_14bits_prm_fx(
    move32();

    return add( bp, i );
#ifdef DEBUG_ari_decode_14bits
printf("ari_start_decoding_14bits_prm_fx: low=0x%08X  high=0x%08X  value=0x%08X  i=%d\n", s->low, s->high, s->value, i);
#endif
}

static Word16 ari_lookup_s17_fx(
@@ -310,11 +318,12 @@ static Word16 ari_lookup_bit_fx(
    UWord16 const *cum_freq /* Q0 */
)
{
    Word16 symbol = 0; /* initialize just to avoid compiler warning */
    Word16 symbol = 0;
    move16();

    (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 );

@@ -328,7 +337,12 @@ static Word16 ari_lookup_bit_fx(
        symbol = 0;
        move16();
    }

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

@@ -356,17 +370,25 @@ 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 );

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

#ifdef DEBUG_ari_decode_14bits
printf("ari_decode_14bits_ext_fx: low=0x%08X  high=0x%08X  value=0x%08X  symbol=0x%04X  range=0x%08X  cum=0x%08X\n", low, high, value, symbol, range, cum);
#endif

    FOR( i = 0; i < 0x7FFF; i++ )
    {
        Word32 L_msb_diff, L_msb_low, L_msb_high;
@@ -386,6 +408,10 @@ static Word16 ari_decode_14bits_ext_fx(
        high = L_shl( high, 1 );
        value = L_msu( value, 1, tab_ari_qnew[L_msb_high][L_msb_low] );
        value = L_mac0( L_shl( value, 1 ), 1, get_next_indice_1_fx( st ) );
#ifdef DEBUG_ari_decode_14bits
       printf("=>low=0x%08X  high=0x%08X  value=0x%08X  dh=%d  dl=%d\n",
              low, high, value, L_msb_high, L_msb_low);
#endif
    }

    s->low = low;