diff --git a/lib_com/bitstream.c b/lib_com/bitstream.c index ed82754b55692f65b9b293ec667d5c97c1c37f70..5b11e8d263f1a6e7aadbc35d95a7e33f6c173ccf 100644 --- a/lib_com/bitstream.c +++ b/lib_com/bitstream.c @@ -893,7 +893,11 @@ ivas_error check_ind_list_limits( } ELSE { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Buffer of indices corrupted in frame %d! Attempt to overwrite indice ID = %d (value: %d, bits: %d)!\n", hBstr->ind_list[hBstr->nb_ind_tot].id, hBstr->ind_list[hBstr->nb_ind_tot].value, hBstr->ind_list[hBstr->nb_ind_tot].nb_bits ); +#ifdef DEBUGGING + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Buffer of indices corrupted in frame %d! Attempt to overwrite indice ID = %d (value: %d, bits: %d)!\n", frame, hBstr->ind_list[hBstr->nb_ind_tot].id, hBstr->ind_list[hBstr->nb_ind_tot].value, hBstr->ind_list[hBstr->nb_ind_tot].nb_bits ); +#else + return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Buffer of indices corrupted! Attempt to overwrite indice ID = %d (value: %d, bits: %d)!\n", hBstr->ind_list[hBstr->nb_ind_tot].id, hBstr->ind_list[hBstr->nb_ind_tot].value, hBstr->ind_list[hBstr->nb_ind_tot].nb_bits ); +#endif } } @@ -2799,7 +2803,11 @@ ivas_error push_indice( /* check the limits of the list of indices */ IF( NE_32( ( error = check_ind_list_limits( hBstr ) ), IVAS_ERR_OK ) ) { - return IVAS_ERROR( error, "Error occured in push_indice() while re-allocating the list of indices (frame %d) !\n" ); +#ifdef DEBUGGING + return IVAS_ERROR( error, "Error occured in push_indice() while re-allocating the list of indices (frame %d) !\n", frame ); +#else + return IVAS_ERROR( error, "Error occured in push_indice() while re-allocating the list of indices!\n" ); +#endif } /* find the location in the list of indices based on ID */ @@ -2957,7 +2965,11 @@ ivas_error push_next_bits( /* check the limits of the list of indices */ IF( NE_32( ( error = check_ind_list_limits( hBstr ) ), IVAS_ERR_OK ) ) { - return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices (frame %d) !\n" ); +#ifdef DEBUGGING + return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices (frame %d) !\n", frame ); +#else + return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices!\n" ); +#endif } ptr = &hBstr->ind_list[hBstr->nb_ind_tot]; @@ -2981,7 +2993,11 @@ ivas_error push_next_bits( /* check the limits of the list of indices */ IF( NE_32( ( error = check_ind_list_limits( hBstr ) ), IVAS_ERR_OK ) ) { - return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices (frame %d) !\n" ); +#ifdef DEBUGGING + return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices (frame %d) !\n", frame ); +#else + return IVAS_ERROR( error, "Error occured in push_next_bits() while re-allocating the list of indices!\n" ); +#endif } ptr = &hBstr->ind_list[hBstr->nb_ind_tot]; @@ -3127,31 +3143,6 @@ UWord16 get_next_indice( return value; } -/*-------------------------------------------------------------------* - * get_next_indice_1() - * - * Get the next 1-bit indice from the buffer - *-------------------------------------------------------------------*/ - -/*! r: value of the indice */ -UWord16 get_next_indice_1( - Decoder_State *st /* i/o: decoder state structure */ -) -{ - Word32 nbits_total; - nbits_total = st->total_brate / FRAMES_PER_SEC; - /* detect corrupted bitstream */ - if ( ( st->next_bit_pos + 1 > nbits_total && st->codec_mode == MODE1 ) || - ( ( st->next_bit_pos + 1 > nbits_total + ( 2 * 8 ) ) && st->codec_mode == MODE2 ) /* add two zero bytes for arithmetic coder flush */ - ) - { - st->BER_detect = 1; - return ( 0 ); - } - - return st->bit_stream[st->next_bit_pos++]; -} - /*-------------------------------------------------------------------* * get_next_indice_tmp() * diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index 02b0a8fa15c04ec02bb4b4c1ef7d8ef0e3a1afb7..ce8d9018e020c3f0aa0e9864fbe5092c9d0caee1 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -327,42 +327,6 @@ void get_next_indice_tmp_fx( move16(); } -/*-------------------------------------------------------------------* - * get_indice_fx( ) - * - * Get indice at specific position in the buffer - *-------------------------------------------------------------------*/ - -UWord16 get_indice_fx( /* o : value of the indice */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 pos, /* i : absolute position in the bitstream (update after the read) */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ -) -{ - UWord16 value; - Word16 i; - - assert( nb_bits <= 16 ); - - /* detect corrupted bitstream */ - IF( GT_16( add( pos, nb_bits ), st_fx->total_num_bits ) ) - { - st_fx->BER_detect = 1; - move16(); - return ( 0 ); - } - - value = 0; - move16(); - FOR( i = 0; i < nb_bits; i++ ) - { - value = lshl( value, 1 ); - value = add( value, st_fx->bit_stream[pos + i] ); - } - - return value; -} - /*-------------------------------------------------------------------* * get_indice_1_fx( ) * @@ -413,179 +377,6 @@ void reset_indices_enc_fx( return; } -/*-------------------------------------------------------------------* - * reset_indices_dec_fx() - * - * Reset the buffer of decoder indices - *-------------------------------------------------------------------*/ - -void reset_indices_dec_fx( - Decoder_State *st_fx ) -{ - st_fx->next_bit_pos = 0; - move16(); - - return; -} - - -/*-------------------------------------------------------------------* - * write_indices_fx() - * - * Write the buffer of indices to a file - *-------------------------------------------------------------------*/ -/*-------------------------------------------------------------------* - * write_indices_buf_fx() - * - * Write the buffer of indices to a file - *-------------------------------------------------------------------*/ -/*-------------------------------------------------------------------* - * indices_to_serial() - * - * pack indices into serialized payload format - *-------------------------------------------------------------------*/ - -void indices_to_serial( - const Encoder_State *st_fx, /* i: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ - Word16 *pFrame_size /* o: size of the binary encoded access unit [bits] */ -) -{ - Word16 i, k, j; - Word16 cmi = 0, core_mode = 0; - Word32 mask; - Word16 amrwb_bits[( ACELP_23k85 / 50 )]; - UWord8 omask = 0x80; - UWord8 *pt_pFrame = pFrame; - Word16 isAmrWb = 0; - move16(); - move16(); - move16(); - move16(); - - IF( st_fx->Opt_AMR_WB ) - { - cmi = rate2EVSmode( st_fx->total_brate, &isAmrWb ); - core_mode = rate2EVSmode( L_mult0( hBstr->nb_bits_tot, 50 ), &isAmrWb ); - - j = 0; - move16(); - 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 ) ); - - /* temporarily save bit */ - FOR( k = 0; k < hBstr->ind_list[i].nb_bits; k++ ) - { - amrwb_bits[j++] = L_and( hBstr->ind_list[i].value, mask ) > 0; - move16(); - mask = L_shr( mask, 1 ); - } - } - } - } - - *pFrame_size = hBstr->nb_bits_tot; - move16(); - - /*----------------------------------------------------------------* - * Bitstream packing (conversion of individual indices into a serial stream) - *----------------------------------------------------------------*/ - j = 0; - move16(); - 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( st_fx->Opt_AMR_WB ) - { - pack_bit( amrwb_bits[sort_ptr[core_mode][j++]], &pt_pFrame, &omask ); - } - ELSE - { - pack_bit( hBstr->ind_list[i].value & mask, &pt_pFrame, &omask ); - j = add( j, 1 ); - } - mask = L_shr( mask, 1 ); - } - } - } - - test(); - IF( st_fx->Opt_AMR_WB && EQ_16( core_mode, AMRWB_IO_SID ) ) /* SID UPD frame always written now .... */ - { - /* insert STI bit and CMI */ - pack_bit( 1, &pt_pFrame, &omask ); - FOR( mask = 0x08; mask > 0; mask >>= 1 ) - { - pack_bit( cmi & mask, &pt_pFrame, &omask ); - } - } -} - - -/*-------------------------------------------------------------------* - * indices_to_serial_generic() - * - * pack indices into serialized payload format - *-------------------------------------------------------------------*/ - -void indices_to_serial_generic( - const Indice *ind_list, /* i: indices list */ - const Word16 num_indices, /* i: number of indices to write */ - UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ - Word16 *pFrame_size /* i/o: number of bits in the binary encoded access unit [bits] */ -) -{ - Word16 i, k, j; - Word32 mask; - UWord8 omask; - UWord8 *pt_pFrame = pFrame; - Word16 nb_bits_tot; - - nb_bits_tot = 0; - move16(); - omask = (UWord8) shr( 0x80, s_and( *pFrame_size, 0x7 ) ); - move16(); - pt_pFrame += shr( *pFrame_size, 3 ); - - /*----------------------------------------------------------------* - * Bitstream packing (conversion of individual indices into a serial stream) - *----------------------------------------------------------------*/ - j = 0; - move16(); - FOR( i = 0; i < num_indices; i++ ){ - IF( NE_16( ind_list[i].nb_bits, -1 ) ){ - /* mask from MSB to LSB */ - mask = L_shl( 1, sub( ind_list[i].nb_bits, 1 ) ); - - /* write bit by bit */ - FOR( k = 0; k < ind_list[i].nb_bits; k++ ) - { - pack_bit( ind_list[i].value & mask, &pt_pFrame, &omask ); - j = add( j, 1 ); - mask = L_shr( mask, 1 ); - } - nb_bits_tot = add( nb_bits_tot, ind_list[i].nb_bits ); -} -} - -*pFrame_size = add( *pFrame_size, nb_bits_tot ); -move16(); - -return; -} - static void dec_prm_core( Decoder_State *st ) { diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 4b9dbc46e221c700a5d927009d8a30c6b63a98e4..145f6a3bf870715a00585cc73eae6f8e3bbcbbd1 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -1242,27 +1242,10 @@ void E_LPC_a_lsf_isf_conversion( Word16 *lpcCoeffs /*Qx*/, Word16 *lsf /*15Q16*/ bitstream_fx.c /========================================================================================================*/ -UWord16 get_next_indice( /* o : value of the indice */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ -); - -UWord16 get_next_indice_fx( /* o : value of the indice */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ -); - -void push_indice_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - 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 */ -); - -void push_next_indice_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - UWord16 value, /* i : value of the quantized indice */ - Word16 nb_bits /* i : number of bits used to quantize the indice */ +/* o : value of the indice */ +UWord16 get_next_indice_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ); Word16 rate2EVSmode( @@ -1270,31 +1253,9 @@ Word16 rate2EVSmode( Word16 *is_amr_wb /* o : (flag) does the bitrate belong to AMR-WB? Can be NULL */ ); -void push_next_bits_fx( - BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ - Word16 bits[], /* i : bit buffer to pack, sequence of single bits */ - Word16 nb_bits /* i : number of bits to pack */ -); - -UWord16 get_indice_fx( /* o : value of the indice */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 pos, /* i : absolute position in the bitstream */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ -); - -UWord16 get_next_indice_1_fx( /* o : value of the indice */ - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -UWord16 get_next_indice_1( /* o : value of the indice */ - Decoder_State *st_fx /* i/o: decoder state structure */ -); -UWord16 get_next_indice_1_fx( /* o : value of the indice */ - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -UWord16 get_next_indice_1_fx( /* o : value of the indice */ - Decoder_State *st_fx /* i/o: decoder state structure */ +/* o : value of the indice */ +UWord16 get_next_indice_1_fx( + Decoder_State *st_fx /* i/o: decoder state structure */ ); void get_next_indice_tmp_fx( @@ -1302,15 +1263,10 @@ void get_next_indice_tmp_fx( Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ); -UWord16 get_indice( /* o : value of the indice */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 pos, /* i : absolute position in the bitstream */ - Word16 nb_bits /* i : number of bits that were used to quantize the indice */ -); - -UWord16 get_indice_1_fx( /* o : value of the indice */ - Decoder_State *st_fx, /* i/o: decoder state structure */ - Word16 pos /* i : absolute position in the bitstream */ +/* o : value of the indice */ +UWord16 get_indice_1_fx( + Decoder_State *st_fx, /* i/o: decoder state structure */ + Word16 pos /* i : absolute position in the bitstream */ ); void reset_indices_enc_fx( @@ -1318,41 +1274,6 @@ void reset_indices_enc_fx( const Word16 max_num_indices /* i : max number of indices */ ); -void reset_indices_dec_fx( - Decoder_State *st_fx /* i/o: decoder state structure */ -); - -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] */ -); - -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 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] */ - UWord16 *num_bits ); - -void indices_to_serial( - const Encoder_State *st_fx, /* i: encoder state structure */ - BSTR_ENC_HANDLE hBstr, /* i/o: encoder state structure */ - UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ - Word16 *pFrame_size /* o: size of the binary encoded access unit [bits] */ -); - -void indices_to_serial_generic( - const Indice *ind_list, /* i: indices list */ - const Word16 num_indices, /* i: number of indices to write */ - UWord8 *pFrame, /* o: byte array with bit packet and byte aligned coded speech data */ - Word16 *pFrame_size /* i/o: number of bits in the binary encoded access unit [bits] */ -); - Word16 BRATE2IDX_fx( Word32 brate ); Word16 BRATE2IDX16k_fx( Word32 brate ); @@ -11061,11 +10982,6 @@ UWord16 get_next_indice( Word16 nb_bits /* i : number of bits that were used to quantize the indice */ ); -/*! r: value of the indice */ -UWord16 get_next_indice_1( - Decoder_State *st /* i/o: decoder state structure */ -); - void get_next_indice_tmp( Decoder_State *st, /* o : decoder state structure */ Word16 nb_bits /* i : number of bits that were used to quantize the indice */