Commit 4bfdfbf4 authored by Jan Kiene's avatar Jan Kiene
Browse files

Accept FIX_2402_REPL_EVS_ARI_CODEC_ENC

parent 6e69ac15
Loading
Loading
Loading
Loading
+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_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  */
#define FIX_BASOP_2555_FRAMELEN_CALC                    /* FhG: BASOP issue 2555: Simplify (sub-)framelength calculation in ivas_mdct_core_tns_ns_fx() */
+0 −16
Original line number Diff line number Diff line
@@ -8491,11 +8491,7 @@ void con_tcx_fx(
    const Word16 *A_cng     /* i  : CNG LP filter coefficients  */
);

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
void ari_start_encoding_14bits_fx(
#else
void ari_start_encoding_14bits_ivas_fx(
#endif
    Tastat *s );
#ifndef FIX_BASOP_2551_HARM_SCALAR_QUAN
void tcx_scalar_quantization_ivas_fx(
@@ -9486,11 +9482,7 @@ void IGFSaveSpectrumForITF_ivas_fx(
    const Word32 *pITFSpectrum,      /* i  : MDCT spectrum                   */
    Word16 exp_pITFSpectrum );

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_ext_fx(
#else
Word16 ari_encode_14bits_ext_ivas_fx(
#endif
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Tastat *s,
@@ -9498,11 +9490,7 @@ Word16 ari_encode_14bits_ext_ivas_fx(
    UWord16 const *cum_freq /* Q0 */
);

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_sign_fx(
#else
Word16 ari_encode_14bits_sign_ivas_fx(
#endif
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word32 bits, /* Q0 */
@@ -9510,11 +9498,7 @@ Word16 ari_encode_14bits_sign_ivas_fx(
    Word16 sign /* Q0 */
);

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_done_encoding_14bits_fx(
#else
Word16 ari_done_encoding_14bits_ivas_fx(
#endif
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Tastat *s );
+0 −12
Original line number Diff line number Diff line
@@ -41,11 +41,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
    CONTEXT_HM_CONFIG *hm_cfg )
{
    Word16 ptr[BITBUFSIZE];
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
    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;
@@ -244,11 +240,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
        bp = ari_encode_14bits_ext_fx( ptr, bp, &as, add( a1, shl( b1, A_THRES_SHIFT ) ), ari_pk_s17_LC_ext[pki] ); /* Q0 */

        /* Check bit budget */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
        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
        {
            ari_copy_states_fx( &as_overflow, &as );
            bp = bp_overflow; /* Q0 */
@@ -278,11 +270,7 @@ void ACcontextMapping_encode2_no_mem_s17_LC_fx(
                    move16();
                    bp = ari_encode_14bits_ext_fx( ptr, bp, &as, 0, ari_pk_s17_LC_ext[pki] ); /* Q0 */

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
                    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
                    {
                        ari_copy_states_fx( &as_overflow, &as );
                        bp = bp_overflow; /* Q0 */
+0 −328
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 * forward declarations
 *-------------------------------------------------------------*/

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
static Word16 ari_encode_14bits_high_low_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -24,7 +23,6 @@ static Word16 ari_encode_14bits_high_low_fx(
    Word32 high, /* Q0 */
    Word32 low   /* Q0 */
);
#endif /* FIX_2402_REPL_EVS_ARI_CODEC_ENC */


/*---------------------------------------------------------------
@@ -36,21 +34,6 @@ static Word16 ari_encode_14bits_high_low_fx(
 * \return none
 *-------------------------------------------------------------*/

#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
void ari_copy_states_fx(
    TastatEnc *source,
    TastatEnc *dest )
{
    dest->low = source->low;
    move32();
    dest->high = source->high;
    move32();
    dest->value = source->value;
    move16();

    return;
}
#endif /* FIX_2402_REPL_EVS_ARI_CODEC_ENC */


/*---------------------------------------------------------------
@@ -62,11 +45,7 @@ void ari_copy_states_fx(
 * \return none
 *-------------------------------------------------------------*/

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
void ari_copy_states_fx(
#else
void ari_copy_states_ivas_fx(
#endif
    Tastat *source,
    Tastat *dest )
{
@@ -96,19 +75,6 @@ void ari_copy_states_ivas_fx(
 * \return none
 *-------------------------------------------------------------*/

#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
void ari_start_encoding_14bits_fx(
    TastatEnc *s )
{
    s->low = L_deposit_l( 0 );
    s->high = ari_q4new + 1;
    move32();
    s->value = 0;
    move16();

    return;
}
#endif /* FIX_2402_REPL_EVS_ARI_CODEC_ENC */

/*---------------------------------------------------------------
 * Ari encoder 14 bits routines
@@ -146,23 +112,6 @@ Word16 ari_put_bit_plus_follow(
 *
 * \return bit consumption
 * ------------------------------------------------------------ - */
#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_done_encoding_14bits_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    TastatEnc *s )
{
    Word16 bit;

    bit = 0;
    move16();
    if ( GE_32( s->low, ari_q1new ) )
    {
        bit = s_xor( bit, 1 );
    }
    return ari_put_bit_plus_follow( ptr, bp, add( s->value, 1 ), bit );
}
#endif /* FIX_2402_REPL_EVS_ARI_CODEC_ENC */

/*---------------------------------------------------------------
 *ari_encode_14bits_ext_fx()
@@ -178,87 +127,8 @@ Word16 ari_done_encoding_14bits_fx(
 *
 * \return bit consumption
 * ------------------------------------------------------------ - */
#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_ext_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    TastatEnc *s,
    Word32 symbol,          /* Q0 */
    UWord16 const *cum_freq /* Q0 */
)
{
    Word32 low;
    Word32 high;
    Word32 range;
    Word16 bits_to_follow;
    Word16 i;
    UWord16 temp;
    Word32 L_temp1, L_temp2;

    high = L_add( s->high, 0 );
    low = L_add( s->low, 0 );
    range = L_sub( high, low ); /* Q0 */

    L_temp1 = L_shl( range, 15 - stat_bitsnew /*both are constants*/ );
    Mpy_32_16_ss( L_temp1, cum_freq[symbol + 1], &L_temp2, &temp );
    if ( symbol != 0 ) /* when symbol is 0, range remains unchanged */
    {
        Mpy_32_16_ss( L_temp1, cum_freq[symbol], &range, &temp );
    }
    high = L_add( low, range );  /* Q0 */
    low = L_add( low, L_temp2 ); /* Q0 */

    bits_to_follow = s->value; /* Q0 */
    move16();

    FOR( i = 0; i < 0x7FFF; i++ )
    {
        IF( LE_32( high, ari_q2new ) )
        {
            bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
            bits_to_follow = 0;
            move16();
        }
        ELSE IF( GE_32( low, ari_q2new ) )
        {
            bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
            bits_to_follow = 0;
            move16();
            low = L_sub( low, ari_q2new );   /* Q0 */
            high = L_sub( high, ari_q2new ); /* Subtract offset to top.  Q0*/
        }
        ELSE
        {
            test();
            IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) )
            {
                /* Output an opposite bit   */
                /* later if in middle half. */
                bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
                low = L_sub( low, ari_q1new );             /* Subtract offset to middle    Q0*/
                high = L_sub( high, ari_q1new );           /* Q0 */
            }
            ELSE
            {
                BREAK; /* Otherwise exit loop.     */
            }
        }

        low = L_add( low, low );    /* Q0 */
        high = L_add( high, high ); /* Scale up code range.     Q0*/
    }

    s->low = low; /* Q0 */
    move32();
    s->high = high; /* Q0 */
    move32();
    s->value = bits_to_follow; /* Q0 */
    move16();
    return bp;
}
#endif /* FIX_2402_REPL_EVS_ARI_CODEC_ENC */

#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
/*------------------------------------------------------------------------
 * Function: ari_encode_overflow_fx()
 *
@@ -266,98 +136,11 @@ Word16 ari_encode_14bits_ext_fx(
 *-------------------------------------------------------------------------*/

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

/*------------------------------------------------------------------------
 * Function: ari_encode_overflow_fx()
 *
 *
 *-------------------------------------------------------------------------*/

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_overflow_fx(
#else
Word16 ari_encode_overflow_ivas_fx(
#endif
    Tastat *s )
{
    return L_sub( L_sub( s->high, 0 ), s->low ) <= 0;
}

#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
/*------------------------------------------------------------------------
 * Function: ari_encode_14bits_high_low()
 *
 *
 *-------------------------------------------------------------------------*/

static Word16 ari_encode_14bits_high_low(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word16 bits, /* Q0 */
    TastatEnc *s,
    Word32 high, /* Q0 */
    Word32 low   /* Q0 */
)
{
    Word16 bits_to_follow, tmp;

    bits_to_follow = s->value;
    move16();

    /* while there are more than 16 bits left */
    tmp = sub( 16, bits ); /* Q0 */
    WHILE( add( add( bp, bits_to_follow ), tmp ) < 0 )
    {
        IF( LE_32( high, ari_q2new ) )
        {
            bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 0 ); /* Q0 */
            bits_to_follow = 0;
            move16();
        }
        ELSE IF( GE_32( low, ari_q2new ) )
        {
            bp = ari_put_bit_plus_follow( ptr, bp, bits_to_follow, 1 ); /* Q0 */
            bits_to_follow = 0;
            move16();
            low = L_sub( low, ari_q2new );   /* Q0 */
            high = L_sub( high, ari_q2new ); /* Subtract offset to top.  Q0*/
        }
        ELSE
        {
            test();
            IF( GE_32( low, ari_q1new ) && LE_32( high, ari_q3new ) )
            {
                /* Output an opposite bit   */
                /* later if in middle half. */
                bits_to_follow = add( bits_to_follow, 1 ); /* Q0 */
                low = L_sub( low, ari_q1new );             /* Subtract offset to middle    Q0*/
                high = L_sub( high, ari_q1new );           /* Q0 */
            }
            ELSE
            {
                BREAK; /* Otherwise exit loop.     */
            }
        }

        low = L_add( low, low );    /* Q0 */
        high = L_add( high, high ); /* Scale up code range.     Q0*/
    }

    s->low = low; /* Q0 */
    move32();
    s->high = high; /* Q0 */
    move32();
    s->value = bits_to_follow; /* Q0 */
    move16();

    return bp;
}
#endif /* FIX_2402_REPL_EVS_ARI_CODEC_ENC */


/*------------------------------------------------------------------------
@@ -366,34 +149,7 @@ static Word16 ari_encode_14bits_high_low(
 * Encode an cumulative frequency interval.
 *-------------------------------------------------------------------------*/

#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_range_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word16 bits, /* Q0 */
    TastatEnc *s,
    Word16 cum_freq_low, /* Q0 */
    Word16 cum_freq_high /* Q0 */
)
{
    Word32 low, high, range;

    range = L_sub( s->high, s->low ); /* 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 */

    return ari_encode_14bits_high_low( ptr, bp, bits, s, high, low );
}

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

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_range_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -412,7 +168,6 @@ Word16 ari_encode_14bits_range_fx(

    return ari_encode_14bits_high_low_fx( ptr, bp, bits, s, high, low );
}
#endif

/*------------------------------------------------------------------------
 * Function: ari_encode_14bits_sign_fx
@@ -420,35 +175,6 @@ Word16 ari_encode_14bits_range_fx(
 * Encode a sign with equal probabilities.
 *-------------------------------------------------------------------------*/

#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_sign_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word16 bits, /* Q0 */
    TastatEnc *s,
    Word16 sign /* Q0 */
)
{
    Word32 low, high, range;
    Word32 L_tmp;

    high = L_add( s->high, 0 );
    low = L_add( s->low, 0 );
    range = L_sub( high, low ); /* Q0 */

    L_tmp = L_shr( range, 1 );
    if ( sign != 0 )
    {
        high = L_add( low, L_tmp ); /* Q0 */
    }
    if ( sign == 0 )
    {
        low = L_add( low, L_tmp ); /* Q0 */
    }

    return ari_encode_14bits_high_low( ptr, bp, bits, s, high, low );
}
#endif /* FIX_2402_REPL_EVS_ARI_CODEC_ENC */


/*------------------------------------------------------------------------
@@ -457,43 +183,6 @@ Word16 ari_encode_14bits_sign_fx(
 * Finish up encoding in CBR mode.
 *-------------------------------------------------------------------------*/

#ifndef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_done_cbr_encoding_14bits_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word16 bits, /* Q0 */
    TastatEnc *s )
{
    Word16 high, tmp, k;

    tmp = sub( bits, 16 ); /* Q0 */
    WHILE( GT_16( sub( tmp, bp ), s->value ) )
    {
        bp = ari_encode_14bits_sign_fx( ptr, bp, bits, s, 0 ); /* Q0 */
    }

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

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

    tmp = s_min( 15, sub( bits, bp ) );
    FOR( k = 0; k < tmp; ++k )
    {
        ptr[bp++] = lshr( high, 15 ); /* Q0 */
        move16();
        high = lshl( high, 1 );
    }

    return bp;
}

/*------------------------------------------------------------------------
 * Function: ari_done_cbr_encoding_14bits_ivas_fx
 *
 * Finish up encoding in CBR mode.
 *-------------------------------------------------------------------------*/
#else
Word16 ari_done_cbr_encoding_14bits_fx(
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
@@ -522,13 +211,8 @@ Word16 ari_done_cbr_encoding_14bits_fx(

    return bp;
}
#endif

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
void ari_start_encoding_14bits_fx(
#else
void ari_start_encoding_14bits_ivas_fx(
#endif
    Tastat *s )
{
    /* : addressing is made with walking pointer s */
@@ -549,11 +233,7 @@ void ari_start_encoding_14bits_ivas_fx(
 * Finish ArCo encoding
 *-------------------------------------------------------------*/

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_done_encoding_14bits_fx(
#else
Word16 ari_done_encoding_14bits_ivas_fx(
#endif
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Tastat *s )
@@ -577,11 +257,7 @@ Word16 ari_done_encoding_14bits_ivas_fx(
 *
 *-------------------------------------------------------------*/

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_ext_fx(
#else
Word16 ari_encode_14bits_ext_ivas_fx(
#endif
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Tastat *s,
@@ -735,11 +411,7 @@ static Word16 ari_encode_14bits_high_low_fx(
 * Encode a sign with equal probabilities.
 *-------------------------------------------------------------------------*/

#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
Word16 ari_encode_14bits_sign_fx(
#else
Word16 ari_encode_14bits_sign_ivas_fx(
#endif
    Word16 *ptr, /* Q0 */
    Word16 bp,   /* Q0 */
    Word32 bits, /* Q0 */
+0 −8
Original line number Diff line number Diff line
@@ -529,11 +529,7 @@ static Word16 tcx_arith_encode(
    Word16 prm[]             /* o  : bit-stream                                Q0 */
)
{
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
    Tastat as, as_lastgood;
#else
    TastatEnc as, as_lastgood;
#endif
    Word16 bp, bp_lastgood;
    Word16 k;
    Word16 kEncoded;
@@ -650,11 +646,7 @@ static Word16 tcx_arith_encode(
    IF( EQ_16( kEncoded, sub( L_frame, 1 ) ) ) /* RESQ bits possibly available */
    {
        /* Limit target bits to actually needed bits */
#ifdef FIX_2402_REPL_EVS_ARI_CODEC_ENC
        target_bits = add( add( bp, 16 ), extract_l( as.bits_to_follow ) );
#else
        target_bits = add( add( bp, 16 ), extract_l( as.value ) );
#endif
    }

    return ari_done_cbr_encoding_14bits_fx( prm, bp, target_bits, &as );
Loading