Commit 13b2e5df authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_2425_REMOVE_RC_DUPLICATES

parent 3fccc102
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -83,7 +83,6 @@
#define FIX_1990_SANITIZER_IN_REVERB_LOAD               /* Nokia: Fix issue part of issue 1990 by introducing missing free of structure - keep until #2059 is addressed */
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define FIX_2425_REMOVE_RC_DUPLICATES                   /* VA: basop issue 2425: Remove duplicated RC encoder functions */
#define HARM_LEV_DURBIN                                 /* VA: basop issue 2423: harmonize levinson-Durbin algorithm */
#define HARMONIZE_TBE2                                  /* VA: basop issue 2399: Remove duplicated code: TBE, step 2 */
#define HARMONIZE_2427_GETPLC                           /* FhG: basop issue : 2427 Harmonizing getPLCDecision functions:*/
+0 −31
Original line number Diff line number Diff line
@@ -4127,13 +4127,6 @@ void rc_enc_finish_fx(
    PVQ_ENC_HANDLE hPVQ    /* i/o: PVQ encoder handle     */
);

#ifndef FIX_2425_REMOVE_RC_DUPLICATES
void rc_enc_finish_ivas_fx(
    BSTR_ENC_HANDLE hBstr,
    PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle     */

);
#endif
void rc_encode_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle               */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                     */
@@ -4142,22 +4135,6 @@ void rc_encode_fx(
    UWord32 tot            /* i  : Total cumulative frequency           Q0*/
);

#ifndef FIX_2425_REMOVE_RC_DUPLICATES
void rc_encode_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle               */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                     */
    UWord32 cum_freq,      /* i  : Cumulative frequency up to symbol    Q0*/
    UWord32 sym_freq,      /* i  : Symbol probability                   Q0*/
    UWord32 tot            /* i  : Total cumulative frequency           Q0*/
);

void rc_enc_uniform_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle              */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                    */
    UWord32 value,         /* i  : Value to encode                     Q0*/
    UWord32 tot            /* i  : Maximum value                       Q0*/
);
#endif
void rc_enc_uniform_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle              */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                    */
@@ -4172,14 +4149,6 @@ void rc_enc_bits_fx(
    Word16 bits            /* i  : Number of bits used                Q0*/
);

#ifndef FIX_2425_REMOVE_RC_DUPLICATES
void rc_enc_bits_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle             */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                   */
    UWord32 value,         /* i  : Value to encode                    Q0*/
    Word16 bits            /* i  : Number of bits used                Q0*/
);
#endif
void re8_compute_base_index_fx(
    const Word16 *x, /* i  : Elemen of Q2, Q3 or Q4                          */
    const Word16 ka, /* i  : Identifier of the absolute leader related to x  */
+0 −12
Original line number Diff line number Diff line
@@ -351,11 +351,7 @@ void pvq_encode_frame_ivas_fx(
        }
    }

#ifdef FIX_2425_REMOVE_RC_DUPLICATES
    rc_enc_finish_fx( hBstr, hPVQ );
#else
    rc_enc_finish_ivas_fx( hBstr, hPVQ );
#endif

    return;
}
@@ -981,11 +977,7 @@ static void densityIndexSymbolEncode_ivas_fx(
            }
        }

#ifdef FIX_2425_REMOVE_RC_DUPLICATES
        rc_encode_fx( hBstr, hPVQ, cum_freq, sym_freq, tot );
#else
        rc_encode_ivas_fx( hBstr, hPVQ, cum_freq, sym_freq, tot );
#endif
    }

    return;
@@ -1154,11 +1146,7 @@ static Word16 calc_pvq_splits_ivas_fx( /* o : Number of
                tmp = 1;
                move16();
            }
#ifdef FIX_2425_REMOVE_RC_DUPLICATES
            rc_enc_bits_fx( hBstr, hPVQ, tmp, 1 );
#else
            rc_enc_bits_ivas_fx( hBstr, hPVQ, tmp, 1 );
#endif
            Np = add( Np, tmp );
        }
    }
+0 −8
Original line number Diff line number Diff line
@@ -365,19 +365,11 @@ void pvq_encode_ivas_fx(
    entry = mpvq_encode_vec_fx( y, dim, pulses );

    /* send the short codeword(s) to the range encoder */
#ifdef FIX_2425_REMOVE_RC_DUPLICATES
    rc_enc_bits_fx( hBstr, hPVQ, UL_deposit_l( entry.lead_sign_ind ), 1 ); /* 0 or 1 */
#else
    rc_enc_bits_ivas_fx( hBstr, hPVQ, UL_deposit_l( entry.lead_sign_ind ), 1 ); /* 0 or 1 */
#endif

    IF( NE_16( dim, 1 ) )
    {
#ifdef FIX_2425_REMOVE_RC_DUPLICATES
        rc_enc_uniform_fx( hBstr, hPVQ, entry.index, entry.size );
#else
        rc_enc_uniform_ivas_fx( hBstr, hPVQ, entry.index, entry.size );
#endif
    }

    return;
+0 −238
Original line number Diff line number Diff line
@@ -17,10 +17,6 @@

static void rc_enc_shift_fx( BSTR_ENC_HANDLE hBstr, PVQ_ENC_HANDLE hPVQ );
static void rc_enc_write_fx( BSTR_ENC_HANDLE hBstr, Word16 byte, Word16 bits );
#ifndef FIX_2425_REMOVE_RC_DUPLICATES
static void rc_enc_shift_ivas_fx( BSTR_ENC_HANDLE hBstr, PVQ_ENC_HANDLE hPVQ );
static void rc_enc_write_ivas_fx( BSTR_ENC_HANDLE hBstr, Word16 byte, Word16 bits );
#endif

/*-------------------------------------------------------------------*
 * rc_enc_init()
@@ -57,46 +53,6 @@ void rc_enc_init_fx(
 *
 *  Encode symbol with range coder
 *-------------------------------------------------------------------*/
#ifndef FIX_2425_REMOVE_RC_DUPLICATES
void rc_encode_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle              */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                    */
    UWord32 cum_freq,      /* i  : Cumulative frequency up to symbol     Q0*/
    UWord32 sym_freq,      /* i  : Symbol probability                    Q0*/
    UWord32 tot            /* i  : Total cumulative frequency            Q0*/
)
{
    UWord32 r, tmp, inv_tot, lsb;
    Word16 exp;
    UWord16 carry;

    inv_tot = UL_inverse( tot, &exp );                   // Q0
    Mpy_32_32_uu( hPVQ->rc_range, inv_tot, &tmp, &lsb ); /*0+exp-32 */
    r = UL_lshr( tmp, sub( exp, 32 ) );                  /* exp-32-exp3+32 = 0 */
    tmp = UL_Mpy_32_32( r, cum_freq );

    hPVQ->rc_low = UL_addNs( hPVQ->rc_low, tmp, &carry ); // Q0
    move32();
    if ( carry != 0 )
    {
        hPVQ->rc_carry = carry; // Q0
        move16();
    }

    hPVQ->rc_range = UL_Mpy_32_32( r, sym_freq ); // Q0
    move32();
    WHILE( LT_64( hPVQ->rc_range, 1 << 24 ) )
    {
        hPVQ->rc_range = UL_lshl( hPVQ->rc_range, 8 ); // Q0
        move32();
        hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, 8 ); // Q0
        move16();
        rc_enc_shift_ivas_fx( hBstr, hPVQ );
    }

    return;
}
#endif

void rc_encode_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle                */
@@ -141,91 +97,6 @@ void rc_encode_fx(
 *  Finalize range coder
 *-------------------------------------------------------------------*/

#ifndef FIX_2425_REMOVE_RC_DUPLICATES
void rc_enc_finish_ivas_fx(
    BSTR_ENC_HANDLE hBstr,
    PVQ_ENC_HANDLE hPVQ /* i/o: PVQ encoder handle     */
)
{
    UWord32 val, mask, high;
    Word16 bits;
    UWord16 over1, over2;

    bits = add( norm_ul( hPVQ->rc_range ), 1 );
    mask = UL_lshr( 0xffffffff, bits );

    val = UL_addNs( hPVQ->rc_low, mask, &over1 );            // Q0
    high = UL_addNs( hPVQ->rc_low, hPVQ->rc_range, &over2 ); // Q0

    val = L_and( val, ~mask );
    L_xor( 0, 0 ); /* For bit not */

    IF( ( L_xor( over1, over2 ) ) == 0 )
    {
        L_sub( 0, 0 ); /* For comparision in if */
        IF( UL_addNsD( val, mask ) >= high )
        {
            bits = add( bits, 1 );                                  // Q0
            mask = UL_lshr( mask, 1 );                              // Q0
            val = UL_and( UL_addNsD( hPVQ->rc_low, mask ), ~mask ); // Q0
            L_xor( 0, 0 );                                          /* For bit not */
        }

        if ( LT_64( val, hPVQ->rc_low ) )
        {
            hPVQ->rc_carry = 1;
            move16();
        }
    }

    hPVQ->rc_low = val;
    move32();

    IF( GT_16( bits, sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits ) ) )
    {
        bits = sub( hPVQ->rc_tot_bits, hPVQ->rc_num_bits ); // Q0
    }

    hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits ); // Q0
    move16();
    FOR( ; bits > 0; bits -= 8 )
    {
        rc_enc_shift_ivas_fx( hBstr, hPVQ );
    }
    bits = add( bits, 8 );

    IF( hPVQ->rc_carry_count > 0 )
    {
        rc_enc_write_ivas_fx( hBstr, add( hPVQ->rc_cache, hPVQ->rc_carry ), 8 );

        FOR( ; hPVQ->rc_carry_count > 1; hPVQ->rc_carry_count-- )
        {
            rc_enc_write_ivas_fx( hBstr, add( hPVQ->rc_carry, 0xff ), 8 );
        }
        rc_enc_write_ivas_fx( hBstr, s_and( add( hPVQ->rc_carry, 0xff ), sub( lshl( 1, bits ), 1 ) ), bits );
    }
    ELSE
    {
        rc_enc_write_ivas_fx( hBstr, lshr( add( hPVQ->rc_cache, hPVQ->rc_carry ), sub( 8, bits ) ), bits );
    }

    bits = hPVQ->rc_num_bits; // Q0
    move16();
    WHILE( LT_16( bits, sub( hPVQ->rc_tot_bits, 16 ) ) )
    {
        rc_enc_write_ivas_fx( hBstr, 0, 16 );
        bits = add( bits, 16 );
    }

    bits = sub( hPVQ->rc_tot_bits, bits ); // Q0
    IF( bits > 0 )
    {
        rc_enc_write_ivas_fx( hBstr, 0, bits );
    }

    return;
}
#endif

void rc_enc_finish_fx(
    BSTR_ENC_HANDLE hBstr,
@@ -316,42 +187,6 @@ void rc_enc_finish_fx(
 *
 *  Shift a byte out to bitstream
 *-------------------------------------------------------------------*/
#ifndef FIX_2425_REMOVE_RC_DUPLICATES
static void rc_enc_shift_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */
    PVQ_ENC_HANDLE hPVQ    /* i/o: PVQ encoder handle       */
)
{
    test();
    L_sub( 0, 0 ); /* For comparision in if */
    IF( LT_64( hPVQ->rc_low, 0xff000000UL ) || EQ_16( hPVQ->rc_carry, 1 ) )
    {
        IF( hPVQ->rc_cache >= 0 )
        {
            rc_enc_write_ivas_fx( hBstr, add( hPVQ->rc_cache, hPVQ->rc_carry ), 8 );
        }

        WHILE( hPVQ->rc_carry_count > 0 )
        {
            rc_enc_write_ivas_fx( hBstr, s_and( add( hPVQ->rc_carry, 0xff ), 255 ), 8 );
            hPVQ->rc_carry_count = sub( hPVQ->rc_carry_count, 1 ); // Q0
            move16();
        }

        hPVQ->rc_cache = u_extract_l( UL_lshr( hPVQ->rc_low, 24 ) );
        hPVQ->rc_carry = 0;
        move16();
    }
    ELSE
    {
        hPVQ->rc_carry_count = add( hPVQ->rc_carry_count, 1 ); // Q0
        move16();
    }
    hPVQ->rc_low = UL_lshl( hPVQ->rc_low, 8 );
    move32();
    return;
}
#endif

static void rc_enc_shift_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle       */
@@ -391,41 +226,6 @@ static void rc_enc_shift_fx(
 *
 *
 *-------------------------------------------------------------------*/
#ifndef FIX_2425_REMOVE_RC_DUPLICATES
void rc_enc_bits_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle             */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                   */
    UWord32 value,         /* i  : Value to encode                    Q0*/
    Word16 bits            /* i  : Number of bits used                Q0*/
)
{
    IF( LE_16( add( rc_get_bits2_fx( hPVQ->rc_num_bits, hPVQ->rc_range ), bits ), hPVQ->rc_tot_bits ) )
    {
        hPVQ->rc_num_bits = add( hPVQ->rc_num_bits, bits ); // Q0
        move16();
        IF( GT_16( bits, 16 ) )
        {
            push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_lshr( value, 16 ) ), sub( bits, 16 ) );
            hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
            move16();
            push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( UL_and( value, 0x0000ffff ) ), 16 );
            hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
            move16();
        }
        ELSE
        {
            push_indice( hBstr, sub( IND_RC_END, hPVQ->rc_offset ), u_extract_l( value ), bits );
            hPVQ->rc_offset = add( hPVQ->rc_offset, 1 ); // Q0
            move16();
        }
    }
    ELSE
    {
    }

    return;
}
#endif

void rc_enc_bits_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle             */
@@ -463,32 +263,6 @@ void rc_enc_bits_fx(
 *
 * Encode with uniform distribution
 *-------------------------------------------------------------------*/
#ifndef FIX_2425_REMOVE_RC_DUPLICATES
void rc_enc_uniform_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle           */
    PVQ_ENC_HANDLE hPVQ,   /* i/o: PVQ encoder handle                 */
    UWord32 value,         /* i  : Value to encode                  Q0*/
    UWord32 tot            /* i  : Maximum value                    Q0*/
)
{
    Word16 n;

    n = sub( 32, norm_ul( UL_subNsD( tot, 1 ) ) );

    IF( LE_16( n, 8 ) )
    {
        rc_encode_ivas_fx( hBstr, hPVQ, value, 1, tot );
    }
    ELSE
    {
        n = sub( n, 8 );
        rc_encode_ivas_fx( hBstr, hPVQ, UL_lshr( value, n ), 1, UL_addNsD( UL_lshr( tot, n ), 1 ) );
        rc_enc_bits_ivas_fx( hBstr, hPVQ, UL_and( value, UL_subNsD( UL_lshl( 1, n ), 1 ) ), n );
    }

    return;
}
#endif

void rc_enc_uniform_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle           */
@@ -520,18 +294,6 @@ void rc_enc_uniform_fx(
 *
 *  Write a byte to bitstream
 *-------------------------------------------------------------------*/
#ifndef FIX_2425_REMOVE_RC_DUPLICATES
static void rc_enc_write_ivas_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle           */
    Word16 byte,           /* i  : Byte to write                    Q0*/
    Word16 bits            /* i  : Number of bits                   Q0*/
)
{
    push_indice( hBstr, IND_RC_START, byte, bits );

    return;
}
#endif

static void rc_enc_write_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle           */