Commit fd227713 authored by JÜRGEN Gerstacker's avatar JÜRGEN Gerstacker
Browse files

removed local macros and replaced by macro in options.h, FIX_2402_SIMPLIFY_ARI_CODEC

parent c5fcb0ae
Loading
Loading
Loading
Loading
Loading
+52 −5
Original line number Diff line number Diff line
@@ -18,12 +18,16 @@
#define MAKE_VARIABLE_QX( variable, QX ) W_shl( W_deposit32_l( L_deposit_l( ( variable ) ) ), ( QX ) ) /* evaluated at run time */


#if 1  //VERSX
#include "issue2402_replacement.h"
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
/* to compare respective values in ivas- and evs-arith-enc calculations */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
#define HIGH(p) ((p)+1)
#define BITS_TO_FOLLOW bits_to_follow
#else
#define HIGH(p) ((p)+0)
#define BITS_TO_FOLLOW value
#endif
#endif



@@ -51,7 +55,11 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
    CONTEXT_HM_CONFIG *hm_cfg )
{
    Word16 ptr[BITBUFSIZE];
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    Tastat    as, as_overflow;
#else
    TastatEnc as, as_overflow;
#endif
    Word16 bp, bp_overflow;
    Word16 a1, b1, a1_i, b1_i, k;
    Word16 t, pki, lev1;
@@ -160,7 +168,11 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
    lsbs_bits2 = ptr + nbbits - 1;

    /*Start Encoding*/
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    ari_start_encoding_14bits_ivas_fx( &as );
#else
    ari_start_encoding_14bits_fx( &as );
#endif

    /*Main Loop through the 2-tuples*/
    b1_i = -1;
@@ -205,7 +217,11 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
        move16();

        /*Copy states*/
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
        ari_copy_states_ivas_fx( &as, &as_overflow );
#else
        ari_copy_states_fx( &as, &as_overflow );
#endif
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
        printf("middle loop: k,lastnz=%d,%d, a1_i,b1_i,idx= %d,%d,%d\n", k,lastnz, a1_i, b1_i, idx );
#endif
@@ -237,8 +253,11 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
            assert( tmp >= 0 && tmp < 4096 );
            pki = ari_lookup_s17_LC[tmp]; /* Q0 */
            move16();
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            bp = ari_encode_14bits_ext_ivas_fx( ptr, bp, &as, VAL_ESC, ari_pk_s17_LC_ext[pki] ); /* Q0 */
#else
            bp = ari_encode_14bits_ext_fx( ptr, bp, &as, VAL_ESC, ari_pk_s17_LC_ext[pki] ); /* Q0 */

#endif
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
            printf("l,h,v= 0x%04x,0x%04x,0x%04x, bp=%03d, a1,b1=0x%04x,0x%04x\n",
              as.low, HIGH(as.high), as.BITS_TO_FOLLOW, bp, a1,b1);
@@ -261,12 +280,24 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
        assert( tmp >= 0 && tmp < 4096 );
        pki = ari_lookup_s17_LC[tmp]; /* Q0 */
        move16();
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
        bp = ari_encode_14bits_ext_ivas_fx( ptr, bp, &as, add( a1, shl( b1, A_THRES_SHIFT ) ), ari_pk_s17_LC_ext[pki] ); /* Q0 */
#else
        bp = ari_encode_14bits_ext_fx( ptr, bp, &as, add( a1, shl( b1, A_THRES_SHIFT ) ), ari_pk_s17_LC_ext[pki] ); /* Q0 */
#endif

        /* Check bit budget */
        IF( GT_16( add( add( add( bp, extract_l( as.BITS_TO_FOLLOW ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
        IF( GT_16( add( add( add( bp, extract_l( as.bits_to_follow ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
#else
        IF( GT_16( add( add( add( bp, extract_l( as.value ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
#endif
        {
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            ari_copy_states_ivas_fx( &as_overflow, &as );
#else
            ari_copy_states_fx( &as_overflow, &as );
#endif
            bp = bp_overflow; /* Q0 */
            move16();

@@ -292,11 +323,23 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
                    assert( t >= 0 && t < 4096 );
                    pki = ari_lookup_s17_LC[t]; /* Q0 */
                    move16();
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
                    bp = ari_encode_14bits_ext_ivas_fx( ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki] ); /* Q0 */
#else
                    bp = ari_encode_14bits_ext_fx( ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki] ); /* Q0 */
#endif

                    IF( GT_16( add( add( add( bp, extract_l( as.BITS_TO_FOLLOW ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
                    IF( GT_16( add( add( add( bp, extract_l( as.bits_to_follow ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
#else
                    IF( GT_16( add( add( add( bp, extract_l( as.value ) ), nbbits_signs ), nbbits_lsbs ), nbbits_m2 ) )
#endif
                    {
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
                        ari_copy_states_ivas_fx( &as_overflow, &as );
#else
                        ari_copy_states_fx( &as_overflow, &as );
#endif
                        bp = bp_overflow; /* Q0 */
                        move16();
                        BREAK;
@@ -343,7 +386,11 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
    } /*end of the 2-tuples loop*/

    /* End arithmetic coder, overflow management */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    bp = ari_done_encoding_14bits_ivas_fx( ptr, bp, &as ); /* Q0 */
#else
    bp = ari_done_encoding_14bits_fx( ptr, bp, &as ); /* Q0 */
#endif

    /* Overflow is detected */
    IF( NE_16( k, lastnz ) )
+158 −21
Original line number Diff line number Diff line
@@ -11,6 +11,19 @@
#include "prot_fx_enc.h" /* Function prototypes                    */


/*---------------------------------------------------------------
 * forward declarations 
 *-------------------------------------------------------------*/

static Word16 ari_encode_14bits_high_low_ivas_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word16 bits, /* Q0 */
    Tastat *s,
    Word32 high, /* Q0 */
    Word32 low   /* Q0 */
);


/*---------------------------------------------------------------
 * ari_copy_states_fx()
@@ -21,7 +34,7 @@
 * \return none
 *-------------------------------------------------------------*/

#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
void ari_copy_states_fx(
    TastatEnc *source,
    TastatEnc *dest )
@@ -35,7 +48,35 @@ void ari_copy_states_fx(

    return;
}
#endif
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */


/*---------------------------------------------------------------
 * ari_copy_states_ivas_fx()
 *
 * \param[i] source
 * \param[o] dest
 *
 * \return none
 *-------------------------------------------------------------*/

void ari_copy_states_ivas_fx(
    Tastat *source,
    Tastat *dest )
{
    dest->low = source->low;
    move32();
    dest->high = source->high;
    move32();
    dest->value = source->value;
    move16();
    dest->bits_to_follow = source->bits_to_follow;
    move16();

    return;
}



/*---------------------------------------------------------------
  Ari encoder 14 bits routines
@@ -50,7 +91,7 @@ void ari_copy_states_fx(
 * \return none
 *-------------------------------------------------------------*/

#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
void ari_start_encoding_14bits_fx(
    TastatEnc *s )
{
@@ -62,7 +103,7 @@ void ari_start_encoding_14bits_fx(

    return;
}
#endif
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */

/*---------------------------------------------------------------
 * Ari encoder 14 bits routines
@@ -106,7 +147,7 @@ Word16 ari_put_bit_plus_follow(
 *
 * \return bit consumption
 * ------------------------------------------------------------ - */
#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
Word16 ari_done_encoding_14bits_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -122,7 +163,7 @@ Word16 ari_done_encoding_14bits_fx(
    }
    return ari_put_bit_plus_follow( ptr, bp, add( s->value, 1 ), bit );
}
#endif
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */

/*---------------------------------------------------------------
 *ari_encode_14bits_ext_fx()
@@ -138,7 +179,7 @@ Word16 ari_done_encoding_14bits_fx(
 *
 * \return bit consumption
 * ------------------------------------------------------------ - */
#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
Word16 ari_encode_14bits_ext_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -219,7 +260,7 @@ Word16 ari_encode_14bits_ext_fx(
#endif
    return bp;
}
#endif
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */

/*------------------------------------------------------------------------
 * Function: ari_encode_overflow_fx()
@@ -227,13 +268,25 @@ Word16 ari_encode_14bits_ext_fx(
 *
 *-------------------------------------------------------------------------*/

#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
Word16 ari_encode_overflow_fx(
    TastatEnc *s )
{
    return L_sub( L_sub( s->high, 1 ), s->low ) <= 0;
}
#endif
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */

/*------------------------------------------------------------------------
 * Function: ari_encode_overflow_ivas_fx()
 *
 *
 *-------------------------------------------------------------------------*/

Word16 ari_encode_overflow_ivas_fx(
    Tastat *s )
{
    return L_sub( L_sub( s->high, 0 ), s->low ) <= 0;
}

/*------------------------------------------------------------------------
 * Function: ari_encode_14bits_high_low()
@@ -241,7 +294,7 @@ Word16 ari_encode_overflow_fx(
 *
 *-------------------------------------------------------------------------*/

#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
static Word16 ari_encode_14bits_high_low(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -312,7 +365,7 @@ static Word16 ari_encode_14bits_high_low(

    return bp;
}
#endif
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */


/*------------------------------------------------------------------------
@@ -321,7 +374,7 @@ static Word16 ari_encode_14bits_high_low(
 * Encode an cumulative frequency interval.
 *-------------------------------------------------------------------------*/

#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
Word16 ari_encode_14bits_range_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -347,8 +400,40 @@ Word16 ari_encode_14bits_range_fx(
#endif
    return ret;
}
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */

/*------------------------------------------------------------------------
 * Function: ari_encode_14bits_range_ivas_fx
 *
 * Encode an cumulative frequency interval.
 *-------------------------------------------------------------------------*/

Word16 ari_encode_14bits_range_ivas_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word16 bits, /* Q0 */
    Tastat *s,
    Word16 cum_freq_low, /* Q0 */
    Word16 cum_freq_high /* Q0 */
)
{
    Word32 low, high, range;

    range = L_sub( s->high, s->low ) + 1; /* Q0 */

    high = L_add( s->low, mul_sbc_14bits( range, cum_freq_high ) ); /* Q0 */
    low = L_add( s->low, mul_sbc_14bits( range, cum_freq_low ) );   /* Q0 */
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
    printf("range, s->low,high=0x%04x,0x%04x   range=0x%04x  low,high=0x%04x,0x%04x\n",
        s->low, s->high+1, range, low, high );
#endif

    Word16 ret = ari_encode_14bits_high_low_ivas_fx( ptr, bp, bits, s, high, low );
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
    printf("range end ret=%d,  s->low,high,value=x%04x,0x%04x,x%04x\n", ret, s->low,s->high+1,s->bits_to_follow);
#endif
    return ret;
}

/*------------------------------------------------------------------------
 * Function: ari_encode_14bits_sign_fx
@@ -356,7 +441,7 @@ Word16 ari_encode_14bits_range_fx(
 * Encode a sign with equal probabilities.
 *-------------------------------------------------------------------------*/

#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
Word16 ari_encode_14bits_sign_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -387,7 +472,7 @@ Word16 ari_encode_14bits_sign_fx(
    Word16 ret = ari_encode_14bits_high_low( ptr, bp, bits, s, high, low );
    return ret;
}
#endif
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */


/*------------------------------------------------------------------------
@@ -396,7 +481,7 @@ Word16 ari_encode_14bits_sign_fx(
 * Finish up encoding in CBR mode.
 *-------------------------------------------------------------------------*/

#if 0  //VERSX
#ifndef FIX_2402_SIMPLIFY_ARI_CODEC
Word16 ari_done_cbr_encoding_14bits_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -444,7 +529,61 @@ Word16 bp0=bp;

    return bp;
}
#endif /* FIX_2402_SIMPLIFY_ARI_CODEC */

/*------------------------------------------------------------------------
 * Function: ari_done_cbr_encoding_14bits_ivas_fx
 *
 * Finish up encoding in CBR mode.
 *-------------------------------------------------------------------------*/

Word16 ari_done_cbr_encoding_14bits_ivas_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word16 bits, /* Q0 */
    Tastat *s )
{
    Word16 high, tmp, k;
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
Word16 bp0=bp;
#endif
    tmp = sub( bits, 16 ); /* Q0 */
    WHILE( GT_16( sub( tmp, bp ), s->bits_to_follow ) )
    {
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
        printf("%s:%d: before  ari_encode_14bits_sign_fx() bp=%d, bits=%d, s=0x%04x,0x%04x,0x%04x\n",
           __FILE__,__LINE__,
           bp, bits, s->low,s->high,s->bits_to_follow);
#endif
        bp = ari_encode_14bits_sign_ivas_fx( ptr, bp, bits, s, 0 ); /* Q0 */
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
        printf("after ari_encode_14bits_sign_fx() bp=%d, bits=%d, s=0x%04x,0x%04x,0x%04x\n",
           bp, bits, s->low,s->high,s->value);
#endif
    }

    high = extract_l( L_sub( s->high, 0 ) ); /* Q0 */

    bp = ari_put_bit_plus_follow( ptr, bp, s->bits_to_follow, lshr( high, 15 ) ); /* Q0 */
    high = lshl( high, 1 );

    tmp = s_min( 15, sub( bits, bp ) );
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
    printf("ari_enc_fx.c:3: bp0=%d bp=%d, bits=%d,s=0x%04x,0x%04x,0x%04x, high=%d,tmp=%d,\n",
       bp0, bp, s->low,s->high,s->BITS_TO_FOLLOW, high, tmp);
#endif
    FOR( k = 0; k < tmp; ++k )
    {
        ptr[bp++] = lshr( high, 15 ); /* Q0 */
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
        printf("ari_enc_fx.c:4: ptr[%d-1]=%d\n", bp, ptr[bp-1]);
#endif
        move16();
        high = lshl( high, 1 );
    }

    return bp;
}


void ari_start_encoding_14bits_ivas_fx(
@@ -578,7 +717,6 @@ Word16 ari_encode_14bits_ext_ivas_fx(
 *
 *-------------------------------------------------------------------------*/

#ifndef  FUNCTION_ari_encode_14bits_high_low_ivas_fx
static Word16 ari_encode_14bits_high_low_ivas_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -590,7 +728,6 @@ static Word16 ari_encode_14bits_high_low_ivas_fx(
{
    Word16 bits_to_follow, tmp;

    //high--;
    bits_to_follow = extract_l( s->bits_to_follow ); /* Q0 */
    move16();
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
@@ -643,7 +780,6 @@ static Word16 ari_encode_14bits_high_low_ivas_fx(

    s->low = low; /* Q0 */
    move32();
    //high++;
    s->high = L_sub( high, 1 ); /* Q0 */
    move32();
    s->bits_to_follow = bits_to_follow; /* Q0 */
@@ -651,7 +787,8 @@ static Word16 ari_encode_14bits_high_low_ivas_fx(

    return bp;
}
#endif



/*------------------------------------------------------------------------
 * Function: ari_encode_14bits_sign_ivas_fx()
+78 −14
Original line number Diff line number Diff line
@@ -11,13 +11,16 @@
#include "basop_util.h"
#include "rom_com.h"

#if 1  //VERSX
#include "issue2402_replacement.h"
#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
/* to compare respective values in ivas- and evs-arith-enc calculations */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
#define HIGH(p) ((p)+1)
#define BITS_TO_FOLLOW bits_to_follow
#else
#define HIGH(p) (p)
#define HIGH(p) ((p)+0)
#define BITS_TO_FOLLOW value
#endif

#endif


/*-------------------------------------------------------------------*
@@ -538,15 +541,24 @@ static Word16 tcx_arith_encode(
    Word16 prm[]             /* o  : bit-stream                                Q0 */
)
{
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    Tastat as, as_lastgood;
#else
    TastatEnc as, as_lastgood;
#endif
    Word16 bp, bp_lastgood;
    Word16 k;
    Word16 kEncoded;
    Word16 tmpi1, tmpi2;

    /* Final coding */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    ari_start_encoding_14bits_ivas_fx( &as );
    ari_copy_states_ivas_fx( &as, &as_lastgood );
#else
    ari_start_encoding_14bits_fx( &as );
    ari_copy_states_fx( &as, &as_lastgood );
#endif
    bp = 0;
    move16();
    bp_lastgood = 0;
@@ -559,8 +571,11 @@ static Word16 tcx_arith_encode(
        IF( q_abs_spectrum[k] == 0 )
        {
            assert( exps[k] >= 2 );
            //printf("%s:%d: before  ari_encode_14bits_range_fx()\n", __FILE__,__LINE__);
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            bp = ari_encode_14bits_range_ivas_fx( prm, bp, target_bits, &as, shr( exps[k], 1 ), 16384 );
#else
            bp = ari_encode_14bits_range_fx( prm, bp, target_bits, &as, shr( exps[k], 1 ), 16384 );
#endif
        }
        ELSE /* q_abs_spectrum[k] != 0 */
        {
@@ -573,21 +588,32 @@ static Word16 tcx_arith_encode(
                powfp_odd2( exps[k], q_abs_spectrum[k], &tmpi1, &tmpi2 );
            }

            //printf("%s:%d: before  ari_encode_14bits_range_fx()\n", __FILE__,__LINE__);
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            bp = ari_encode_14bits_range_ivas_fx( prm, bp, target_bits, &as, shr( tmpi2, 1 ), shr( tmpi1, 1 ) );
            bp = ari_encode_14bits_sign_ivas_fx( prm, bp, target_bits, &as, signs[k] );
#else
            bp = ari_encode_14bits_range_fx( prm, bp, target_bits, &as, shr( tmpi2, 1 ), shr( tmpi1, 1 ) );
            //printf("%s:%d: before  ari_encode_14bits_sign_fx()\n", __FILE__,__LINE__);
            bp = ari_encode_14bits_sign_fx( prm, bp, target_bits, &as, signs[k] );
#endif
        }

        /* Check bit budget status */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
        IF( ari_encode_overflow_ivas_fx( &as ) ) /* no bits left */
#else
        IF( ari_encode_overflow_fx( &as ) ) /* no bits left */
#endif
        {
            /* printf("\noverflow at %d\n\n", k); */

            IF( GT_16( q_abs_spectrum[k], 1 ) ) /* Lower magnitude is still > 0 */
            {
                /* Restore state */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
                ari_copy_states_ivas_fx( &as_lastgood, &as );
#else
                ari_copy_states_fx( &as_lastgood, &as );
#endif
                bp = bp_lastgood;
                move16();

@@ -598,14 +624,25 @@ static Word16 tcx_arith_encode(
                /* Retry encoding */
                powfp_odd2( exps[k], q_abs_spectrum[k], &tmpi1, &tmpi2 );

                //printf("%s:%d: before  ari_encode_14bits_range_fx()\n", __FILE__,__LINE__);
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
                bp = ari_encode_14bits_range_ivas_fx( prm, bp, target_bits, &as, shr( tmpi2, 1 ), shr( tmpi1, 1 ) );
                bp = ari_encode_14bits_sign_ivas_fx( prm, bp, target_bits, &as, signs[k] );
#else
                bp = ari_encode_14bits_range_fx( prm, bp, target_bits, &as, shr( tmpi2, 1 ), shr( tmpi1, 1 ) );
                //printf("%s:%d: before  ari_encode_14bits_sign_fx()\n", __FILE__,__LINE__);
                bp = ari_encode_14bits_sign_fx( prm, bp, target_bits, &as, signs[k] );
#endif

#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
                IF( !ari_encode_overflow_ivas_fx( &as ) ) /* Success */
#else
                IF( !ari_encode_overflow_fx( &as ) ) /* Success */
#endif
                {
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
                    ari_copy_states_ivas_fx( &as, &as_lastgood );
#else
                    ari_copy_states_fx( &as, &as_lastgood );
#endif
                    bp_lastgood = bp;
                    move16();
                    kEncoded = k;
@@ -615,7 +652,11 @@ static Word16 tcx_arith_encode(
                    BREAK;
                }
            }
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            ari_copy_states_ivas_fx( &as_lastgood, &as );
#else
            ari_copy_states_fx( &as_lastgood, &as );
#endif
            bp = bp_lastgood;
            move16();
            kEncoded = sub( k, 1 );
@@ -625,7 +666,11 @@ static Word16 tcx_arith_encode(
        }
        ELSE
        {
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            ari_copy_states_ivas_fx( &as, &as_lastgood );
#else
            ari_copy_states_fx( &as, &as_lastgood );
#endif
            bp_lastgood = bp;
            move16();
        }
@@ -638,12 +683,23 @@ static Word16 tcx_arith_encode(
    {
        assert( exps[k] >= 1 );

        //printf("%s:%d: before  ari_encode_14bits_range_fx()\n", __FILE__,__LINE__);
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
        bp = ari_encode_14bits_range_ivas_fx( prm, bp, target_bits, &as, shr( exps[k], 1 ), 16384 );
#else
        bp = ari_encode_14bits_range_fx( prm, bp, target_bits, &as, shr( exps[k], 1 ), 16384 );
#endif
        /* Check bit budget status */
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
        IF( ari_encode_overflow_ivas_fx( &as ) ) /* no bits left */
#else
        IF( ari_encode_overflow_fx( &as ) ) /* no bits left */
#endif
        {
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            ari_copy_states_ivas_fx( &as_lastgood, &as );
#else
            ari_copy_states_fx( &as_lastgood, &as );
#endif
            bp = bp_lastgood;
            move16();
            kEncoded = sub( k, 1 );
@@ -651,7 +707,11 @@ static Word16 tcx_arith_encode(
        }
        ELSE
        {
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
            ari_copy_states_ivas_fx( &as, &as_lastgood );
#else
            ari_copy_states_fx( &as, &as_lastgood );
#endif
            bp_lastgood = bp;
            move16();
        }
@@ -660,7 +720,11 @@ static Word16 tcx_arith_encode(
    IF( EQ_16( kEncoded, sub( L_frame, 1 ) ) ) /* RESQ bits possibly available */
    {
        /* Limit target bits to actually needed bits */
        target_bits = add( add( bp, 16 ), extract_l( as.BITS_TO_FOLLOW ) );
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
        target_bits = add( add( bp, 16 ), extract_l( as.bits_to_follow ) );
#else
        target_bits = add( add( bp, 16 ), extract_l( as.value ) );
#endif
    }

#ifdef DEBUG_ARITH_IVAS_REPLACEMENT
@@ -668,10 +732,10 @@ static Word16 tcx_arith_encode(
       __FILE__,__LINE__,
      bp, target_bits, as.low,HIGH(as.high),as.BITS_TO_FOLLOW );
#endif
#ifdef FIX_2402_SIMPLIFY_ARI_CODEC
    Word16 ret = ari_done_cbr_encoding_14bits_ivas_fx( prm, bp, target_bits, &as );
#else
    Word16 ret = ari_done_cbr_encoding_14bits_fx( prm, bp, target_bits, &as );
#if 0
    printf("after ari_done_cbr_encoding_14bits_fx() ret=%d, as=0x%04x,0x%04x,0x%04x\n",
       ret,  as.low,HIGH(as.high),as.BITS_TO_FOLLOW);
#endif
    return ret;
}
+51 −5

File changed.

Preview size limit exceeded, changes collapsed.

lib_enc/issue2402_replacement.h

deleted100644 → 0
+0 −259

File deleted.

Preview size limit exceeded, changes collapsed.

Loading