Commit 95a6efce authored by thomas dettbarn's avatar thomas dettbarn
Browse files

applied the patches from the review.

parent 0a0a50ba
Loading
Loading
Loading
Loading
Loading
+42 −43
Original line number Diff line number Diff line
@@ -1234,14 +1234,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
    UWord16 t;
    Word16 lastnz, lastnz2;
    Word16 rateFlag;
    Word64 bit_estimate_accu;
    Word64 bit_estimate_fx;

    Word16 symbol;
    const UWord8 *lookup;
    Word64 nbits2_accu; 

    /* Initialization */
    bit_estimate_accu = MAKE_NUMBER_QX(2, Q23 );
    bit_estimate_fx = MAKE_NUMBER_QX(2, Q23 );
    move64();

    nbits2_accu = 0;
@@ -1255,14 +1255,14 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(

    WHILE( LT_16( k, nt / 2 ) )
    {
        bit_estimate_accu = W_add( bit_estimate_accu, MAKE_NUMBER_QX(1, Q23 ) );
        bit_estimate_fx = W_add( bit_estimate_fx, MAKE_NUMBER_QX(1, Q23 ) );
        k = shl( k, 1 );
        i = add( i, 2 );
        /* check while condition */
 
    }

    nbits2_accu = bit_estimate_accu;
    nbits2_accu = bit_estimate_fx;
    move64();

    IF( hm_cfg )
@@ -1350,8 +1350,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            b1 = (Word16) abs( x[b1_i] );
            lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );

            bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) );
            bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) );
            bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) );
            bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) );
            /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
            lookup = &ari_lookup_s17_LC[t] + ( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) );

@@ -1361,8 +1361,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            {
                pki = lookup[lev1]; /* ESC symbol */

                bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
                bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) );
                bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
                bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX(2, Q23 ) );
                a1 = shr( a1, 1 );
                b1 = shr( b1, 1 );

@@ -1374,10 +1374,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            pki = lookup[lev1];

            symbol = add( a1, i_mult( A_THRES, b1 ) );                                                                                                  /* Q0 */
            bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] );
            bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] );

            /* Should we truncate? */
            IF( GT_32( W_shr( bit_estimate_accu, Q8 ), L_shl( target, Q15 ) ) )
            IF( GT_32( W_shr( bit_estimate_fx, Q8 ), L_shl( target, Q15 ) ) )
            {
                stop2 = 1;
                move16();
@@ -1390,7 +1390,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            ELSE
            {
                lastnz2 = add( b1_i, 1 );
                nbits2_accu = bit_estimate_accu; 
                nbits2_accu = bit_estimate_fx; 
                move64();
            }

@@ -1432,7 +1432,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(

        } /*end of the 2-tuples loop*/

        total_output_bits = round_fx( W_shr(bit_estimate_accu, Q7 ) );
        total_output_bits = round_fx( W_shr(bit_estimate_fx, Q7 ) );

        IF( *stop )
        {
@@ -1528,8 +1528,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            move16();
            rateQ = add( rateFlag, extract_l( GT_16( k, shr( nt, 1 ) ) ) ); /* Q0 */

            bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) );
            bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) );
            bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) );
            bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) );

            /* pre-compute address of ari_pk_s17_LC_ext[0][Val_esc] to avoid doing it multiple times inside the loop */
            lookup = &ari_lookup_s17_LC[t + shl( rateQ, NBITS_CONTEXT )]; /* Q0 */
@@ -1541,8 +1541,8 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
                pki = lookup[( esc_nb << ( NBITS_CONTEXT + NBITS_RATEQ ) )]; /* Q0 */
                move16();

                bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
                bit_estimate_accu = W_add_nosat( bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) );
                bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
                bit_estimate_fx = W_add_nosat( bit_estimate_fx, MAKE_VARIABLE_QX(2, Q23 ) );

                a1 = shr( a1, 1 );
                b1 = shr( b1, 1 );
@@ -1557,10 +1557,10 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            move16();

            symbol = add( a1, i_mult( A_THRES, b1 ) );                                                                                                  /* Q0 */
            bit_estimate_accu = W_add_nosat( bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] );
            bit_estimate_fx = W_add_nosat( bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] );

            /* Should we truncate? */
            IF( GT_32( W_shr( bit_estimate_accu, Q8 ), L_shl( target, Q15 ) ) )
            IF( GT_32( W_shr( bit_estimate_fx, Q8 ), L_shl( target, Q15 ) ) )
            {
                overflow_flag = 1;
                move16();
@@ -1569,7 +1569,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            {
                IF( abs_s( x[k] ) || abs_s( x[k + 1] ) ) /* No overflow & non-zero tuple */
                {
                    nbits2_accu = bit_estimate_accu; /* exp(bit_estimate_e) */
                    nbits2_accu = bit_estimate_fx; /* exp(bit_estimate_e) */
                    move64();

                    lastnz2 = add( k, 2 );
@@ -1599,7 +1599,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
        }
        IF( EQ_16( mode, -1 ) )
        {
            tot_bits2 = round_fx( W_shr( bit_estimate_accu, Q7 ) );
            tot_bits2 = round_fx( W_shr( bit_estimate_fx, Q7 ) );
        }
        IF( overflow_flag == 0 ) /* No overflow */
        {
@@ -1614,7 +1614,7 @@ Word16 RCcontextMapping_encode2_estimate_no_mem_s17_LCS_fx(
            }
            ELSE
            {
                *stop = round_fx( W_shr( bit_estimate_accu, Q7 ) );
                *stop = round_fx( W_shr( bit_estimate_fx, Q7 ) );
                move16();
            }
        }
@@ -1665,7 +1665,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(
        move16();
    }

    hContextMem->bit_estimate_accu = MAKE_NUMBER_QX(2, Q23 );
    hContextMem->bit_estimate_fx = MAKE_NUMBER_QX(2, Q23 );
    move64();
    

@@ -1682,7 +1682,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_start_fx(

    WHILE( LT_16( k, hContextMem->nt_half ) )
    {
        hContextMem->bit_estimate_accu = W_add( hContextMem->bit_estimate_accu, MAKE_NUMBER_QX(1, Q23 ) );
        hContextMem->bit_estimate_fx = W_add( hContextMem->bit_estimate_fx, MAKE_NUMBER_QX( 1, Q23 ) );
        move64();

        k = shl( k, 1 );
@@ -1769,8 +1769,8 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
        lev1 = -( 1 << ( NBITS_CONTEXT + NBITS_RATEQ ) ); /* Q0 */

        /* Signs Bits */
        hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) );
        hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) );
        hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( a1, 1 ), Q23 ) );
        hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( s_min( b1, 1 ), Q23 ) );

        move32();
        move32();
@@ -1785,13 +1785,12 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
            pki = lookup[lev1]; /* Q0 */
            move16();

            hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
            hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, MAKE_VARIABLE_QX(2, Q23 ) );
            hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][VAL_ESC] );
            hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, MAKE_VARIABLE_QX( 2, Q23 ) );
            move32();
            move32();



            // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][VAL_ESC];
            // hContextMem->bit_estimate += 2; /* Add the 2 LSB bits that were shifted out */

@@ -1805,7 +1804,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
        pki = lookup[lev1]; /* Q0 */
        move16();
        symbol = add( a1, i_mult( A_THRES, b1 ) ); /* MSB symbol    Q0*/
        hContextMem->bit_estimate_accu = W_add_nosat( hContextMem->bit_estimate_accu, ari_bit_estimate_s17_LC_fx[pki][symbol] );
        hContextMem->bit_estimate_fx = W_add_nosat( hContextMem->bit_estimate_fx, ari_bit_estimate_s17_LC_fx[pki][symbol] );

        move32();
        // hContextMem->bit_estimate = hContextMem->bit_estimate + ari_bit_estimate_s17_LC[pki][symbol];
@@ -1826,7 +1825,7 @@ Word16 RCcontextMapping_encode2_estimate_bandWise_fx(
        move16();

    }                                                                            /*end of the 2-tuples loop*/
    total_output_bits = round_fx( W_shr( hContextMem->bit_estimate_accu, Q7 ) ); /* Q0 */
    total_output_bits = round_fx( W_shr( hContextMem->bit_estimate_fx, Q7 ) ); /* Q0 */
    // total_output_bits = (Word16) ( hContextMem->bit_estimate + 0.5f );


+1 −1
Original line number Diff line number Diff line
@@ -2348,7 +2348,7 @@ typedef struct context_rc_mem_struct
{
    int16_t nbits_old;
    int16_t ctx;
    Word64 bit_estimate_accu;
    Word64 bit_estimate_fx;
    int16_t rateFlag;
    int16_t lastnz;
    int16_t nt_half;