Commit 09d041c8 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'accepted_macro_cleanup' into 'main'

Cleanup macros in options.h

See merge request !1824
parents 097e2392 edeae111
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1062,7 +1062,6 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, Word32 y, Word16 *s )
    return z;
}

#ifdef DIV32_OPT_NEWTON
Word32 div_w_newton( Word32 num, Word32 den );
/*
Table of 256 precalculated estimates to be used by the "div_w_newton"
@@ -1462,7 +1461,6 @@ Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x, Word32 y, Word16 *s )

    return z;
}
#endif /* DIV32_OPT_NEWTON */

Word16 BASOP_Util_Divide3232_Scale( Word32 x, Word32 y, Word16 *s )
{
+0 −2
Original line number Diff line number Diff line
@@ -333,11 +333,9 @@ Word32 BASOP_Util_Divide3232_Scale_cadence( Word32 x, /*!< i : Numerator*/
                                            Word16 *s ); /*!< o  : Additional scalefactor difference*/


#ifdef DIV32_OPT_NEWTON
Word32 BASOP_Util_Divide3232_Scale_newton( Word32 x,    /*!< i  : Numerator*/
                                           Word32 y,    /*!< i  : Denominator*/
                                           Word16 *s ); /*!< o  : Additional scalefactor difference*/
#endif


/************************************************************************/
+0 −334
Original line number Diff line number Diff line
@@ -242,130 +242,6 @@ Word16 rate2EVSmode(
 *
 * Push a new indice into the buffer
 *-------------------------------------------------------------------*/
#ifndef HARM_PUSH_BIT
void push_indice_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
    Word16 id,             /* i  : ID of the indice */
    UWord16 value,         /* i  : value of the quantized indice */
    Word16 nb_bits         /* i  : number of bits used to quantize the indice */
)
{
    Word16 i;


    IF( EQ_16( hBstr->last_ind_fx, id ) )
    {
        /* indice with the same name as the previous one */
        i = hBstr->next_ind_fx;
        move16();
    }
    ELSE
    {
        /* new indice - find an empty slot in the list */
        i = id;
        move16();
        WHILE( hBstr->ind_list[i].nb_bits != -1 )
        {
            i = add( i, 1 );
        }
    }

    /* store the values in the list */
    hBstr->ind_list[i].value = value;
    move16();
    hBstr->ind_list[i].nb_bits = nb_bits;
    move16();

    /* updates */
    hBstr->next_ind_fx = add( i, 1 );
    move16();
    hBstr->last_ind_fx = id;
    move16();
    hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
    move16();

    return;
}
/*-------------------------------------------------------------------*
 * push_next_indice()            *
 * Push a new indice into the buffer at the next position
 *-------------------------------------------------------------------*/

void push_next_indice_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
    UWord16 value,         /* i  : value of the quantized indice */
    Word16 nb_bits         /* i  : number of bits used to quantize the indice */
)
{

    /* store the values in the list */
    hBstr->ind_list[hBstr->next_ind_fx].value = value;
    move16();
    hBstr->ind_list[hBstr->next_ind_fx].nb_bits = nb_bits;
    move16();
    hBstr->next_ind_fx = add( hBstr->next_ind_fx, 1 );
    move16();

    /* update the total number of bits already written */
    hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
    move16();

    return;
}


/*-------------------------------------------------------------------*
 * push_next_bits()
 * Push a bit buffer into the buffer at the next position
 *-------------------------------------------------------------------*/

void push_next_bits_fx(
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
    Word16 bits[],         /* i  : bit buffer to pack, sequence of single bits */
    Word16 nb_bits         /* i  : number of bits to pack */
)
{
    UWord16 code;
    Word16 i, nb_bits_m15;
    Indice *ptr;

    ptr = &hBstr->ind_list[hBstr->next_ind_fx];
    nb_bits_m15 = sub( nb_bits, 15 );
    i = 0;
    move16();
    IF( nb_bits_m15 > 0 )
    {
        FOR( ; i < nb_bits_m15; i += 16 )
        {
            code = s_or( lshl( bits[i], 15 ), s_or( lshl( bits[i + 1], 14 ), s_or( lshl( bits[i + 2], 13 ), s_or( lshl( bits[i + 3], 12 ),
                                                                                                                  s_or( lshl( bits[i + 4], 11 ), s_or( lshl( bits[i + 5], 10 ), s_or( lshl( bits[i + 6], 9 ), s_or( lshl( bits[i + 7], 8 ),
                                                                                                                                                                                                                    s_or( lshl( bits[i + 8], 7 ), s_or( lshl( bits[i + 9], 6 ), s_or( lshl( bits[i + 10], 5 ), s_or( lshl( bits[i + 11], 4 ),
                                                                                                                                                                                                                                                                                                                     s_or( lshl( bits[i + 12], 3 ), s_or( lshl( bits[i + 13], 2 ), s_or( lshl( bits[i + 14], 1 ), bits[i + 15] ) ) ) ) ) ) ) ) ) ) ) ) ) ) );

            ptr->value = code;
            move16();
            ptr->nb_bits = 16;
            move16();
            ++ptr;
        }
    }
    IF( LT_16( i, nb_bits ) )
    {
        FOR( ; i < nb_bits; ++i )
        {
            ptr->value = bits[i];
            move16();
            ptr->nb_bits = 1;
            move16();
            ++ptr;
        }
    }
    hBstr->next_ind_fx = (Word16) ( ptr - hBstr->ind_list );
    move16();
    hBstr->nb_bits_tot = add( hBstr->nb_bits_tot, nb_bits );
    move16();
}
#endif

/*-------------------------------------------------------------------*
 * get_next_indice_fx( )
@@ -528,12 +404,6 @@ void reset_indices_enc_fx(
    move16();
    hBstr->nb_bits_tot = 0;
    move16();
#ifndef HARM_PUSH_BIT
    hBstr->next_ind_fx = 0;
    move16();
    hBstr->last_ind_fx = -1;
    move16();
#endif
    FOR( i = 0; i < max_num_indices; i++ )
    {
        hBstr->ind_list[i].nb_bits = -1;
@@ -564,215 +434,11 @@ void reset_indices_dec_fx(
 *
 * Write the buffer of indices to a file
 *-------------------------------------------------------------------*/
#ifndef HARM_PUSH_BIT
void write_indices_fx(
    Encoder_State *st_fx,  /* i/o: encoder state structure */
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
    FILE *file             /* i  : output bitstream file   */
    ,
    UWord8 *pFrame,    /* i: byte array with bit packet and byte aligned coded speech data */
    Word16 pFrame_size /* i: size of the binary encoded access unit [bits] */
)
{
    Word16 i, k;
    Word16 stream[2 + MAX_BITS_PER_FRAME], *pt_stream;
    Word32 mask;
    UWord8 header;
    Word16 isAmrWb = 0;
    move16();

    IF( st_fx->bitstreamformat == G192 )
    {
        /*-----------------------------------------------------------------*
         * Encode Sync Header and Frame Length
         *-----------------------------------------------------------------*/
        pt_stream = stream;
        FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i )
        {
            stream[i] = 0;
            move16();
        }
        *pt_stream++ = SYNC_GOOD_FRAME;
        move16();
        *pt_stream++ = hBstr->nb_bits_tot;
        move16();

        /*----------------------------------------------------------------*
         * Bitstream packing (conversion of individual indices into a serial stream)
         * Writing the serial stream into file
         *----------------------------------------------------------------*/

        FOR( i = 0; i < MAX_NUM_INDICES; i++ )
        {
            IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
            {
                /* mask from MSB to LSB */
                mask = L_shl( 1, sub( hBstr->ind_list[i].nb_bits, 1 ) );

                /* write bit by bit */
                FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
                {
                    IF( L_and( hBstr->ind_list[i].value, mask ) )
                    {
                        *pt_stream++ = G192_BIN1;
                        move16();
                    }
                    ELSE
                    {
                        *pt_stream++ = G192_BIN0;
                        move16();
                    }

                    mask = L_shr( mask, 1 );
                }
            }
        }
    }
    ELSE
    {
        /* Create and write ToC header */
        /*  qbit always  set to  1 on encoder side  for AMRWBIO ,  no qbit in use for EVS, but set to 0(bad)  */
        header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) );
        move16();
        fwrite( &header, sizeof( UWord8 ), 1, file );
        /* Write speech bits */
        fwrite( pFrame, sizeof( UWord8 ), shr( add( pFrame_size, 7 ), 3 ), file );
    }

    /* Clearing of indices */
    FOR( i = 0; i < MAX_NUM_INDICES; i++ )
    {
        hBstr->ind_list[i].nb_bits = -1;
        move16();
    }


    IF( st_fx->bitstreamformat == G192 )
    {
        /* write the serial stream into file */
        fwrite( stream, sizeof( unsigned short ), 2 + stream[1], file );
    }
    /* reset index pointers */
    hBstr->nb_bits_tot = 0;
    move16();
    hBstr->next_ind_fx = 0;
    move16();
    hBstr->last_ind_fx = -1;
    move16();

    return;
}
#endif
/*-------------------------------------------------------------------*
 * write_indices_buf_fx()
 *
 * Write the buffer of indices to a file
 *-------------------------------------------------------------------*/
#ifndef HARM_PUSH_BIT
void write_indices_buf_fx(
    Encoder_State *st_fx,  /* i/o: encoder state structure */
    BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */
    UWord16 *out_buf,      /* i  : output bitstream buf   */
    UWord8 *pFrame,        /* i: byte array with bit packet and byte aligned coded speech data */
    Word16 pFrame_size,    /* i: size of the binary encoded access unit [bits] */
    UWord16 *num_bits )
{
    Word16 i, k;
    Word16 stream[2 + MAX_BITS_PER_FRAME], *pt_stream;
    Word32 mask;
    UWord8 header;
    Word16 isAmrWb = 0;

    IF( st_fx->bitstreamformat == G192 )
    {
        /*-----------------------------------------------------------------*
         * Encode Sync Header and Frame Length
         *-----------------------------------------------------------------*/
        pt_stream = stream;
        FOR( i = 0; i < ( 2 + MAX_BITS_PER_FRAME ); ++i )
        {
            stream[i] = 0;
            move16();
        }
        //*pt_stream++ = (Word16) SYNC_GOOD_FRAME;
        //*pt_stream++ = hBstr->nb_bits_tot;
        *num_bits = hBstr->nb_bits_tot;
        move16();
        /*----------------------------------------------------------------*
         * Bitstream packing (conversion of individual indices into a serial stream)
         * Writing the serial stream into file
         *----------------------------------------------------------------*/
        FOR( i = 0; i < MAX_NUM_INDICES; i++ )
        {
            IF( NE_16( hBstr->ind_list[i].nb_bits, -1 ) )
            {
                /* mask from MSB to LSB */
                mask = L_shl( 1, ( sub( hBstr->ind_list[i].nb_bits, 1 ) ) );

                /* write bit by bit */
                FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ )
                {
                    IF( L_and( hBstr->ind_list[i].value, mask ) )
                    {
                        //*pt_stream++ = G192_BIN1;
                        *pt_stream++ = 1;
                        move16();
                    }
                    ELSE
                    {
                        //*pt_stream++ = G192_BIN0;
                        *pt_stream++ = 0;
                        move16();
                    }

                    mask = L_shr( mask, 1 );
                }
            }
        }
    }
    ELSE
    {
        /* Create and write ToC header */
        /*  qbit always  set to  1 on encoder side  for AMRWBIO ,  no qbit in use for EVS, but set to 0(bad)  */
        header = (UWord8) ( s_or( s_or( shl( st_fx->Opt_AMR_WB, 5 ), shl( st_fx->Opt_AMR_WB, 4 ) ), rate2EVSmode( i_mult( hBstr->nb_bits_tot, 50 ), &isAmrWb ) ) );
        // fwrite(&header, sizeof(UWord8), 1, file);
        memcpy( out_buf, &header, sizeof( UWord8 ) );
        *num_bits += sizeof( UWord8 );
        /* Write speech bits */
        // fwrite(pFrame, sizeof(UWord8), (pFrame_size + 7) >> 3, file);
        memcpy( out_buf, pFrame, sizeof( UWord8 ) * ( shr( add( pFrame_size, 7 ), 3 ) ) );
        *num_bits += sizeof( UWord8 ) * ( shr( ( add( pFrame_size, 7 ) ), 3 ) );
    }

    /* Clearing of indices */
    FOR( i = 0; i < MAX_NUM_INDICES; i++ )
    {
        hBstr->ind_list[i].nb_bits = -1;
        move16();
    }


    IF( st_fx->bitstreamformat == G192 )
    {
        /* write the serial stream into file */
        // fwrite(stream, sizeof(unsigned short), 2 + stream[1], file);
        // FILE *ftemp = fopen( "./output/bitstreams/out.COD", "ab" );
        // fwrite( stream, sizeof( unsigned short ), 2 + stream[1], ftemp );
        // fclose( ftemp );
        memcpy( out_buf, stream, sizeof( unsigned short ) * ( *num_bits ) );
        //*num_bits += sizeof( unsigned short ) * ( 2 + stream[1] );
    }
    /* reset index pointers */
    hBstr->nb_bits_tot = 0;
    hBstr->next_ind_fx = 0;
    hBstr->last_ind_fx = -1;
    move16();
    move16();
    move16();

    return;
}
#endif
/*-------------------------------------------------------------------*
 * indices_to_serial()
 *
+21 −80

File changed.

Preview size limit exceeded, changes collapsed.

+0 −8
Original line number Diff line number Diff line
@@ -534,15 +534,7 @@ enum
    IND_STEREO_ICBWE_MSFLAG,
    IND_SHB_ENER_SF,
    IND_SHB_RES_GS,
#ifndef FIX_1486_IND_SHB_RES
    IND_SHB_RES_GS1,
    IND_SHB_RES_GS2,
    IND_SHB_RES_GS3,
    IND_SHB_RES_GS4,
    IND_SHB_VF,
#else
    IND_SHB_VF = IND_SHB_RES_GS + 5,
#endif
    IND_SHB_LSF,
    IND_SHB_MIRROR = IND_SHB_LSF + 5,
    IND_SHB_GRID,
Loading