Loading apps/encoder.c +3 −3 Original line number Diff line number Diff line Loading @@ -720,9 +720,9 @@ int main( #ifdef DEBUG_IND { int16_t tmp_i = -1; dbgwrite( &tmp_i, sizeof( int16_t ), 1, 960 - total_num_id, "res/ind_list.x" ); //int16_t tmp_i = -1; //dbgwrite( &tmp_i, sizeof( int16_t ), 1, 960 - total_num_id, "res/ind_list.x" ); dbgwrite( &total_num_id, sizeof( int16_t ), 1, 1, "res/ind_total_num.x" ); } #endif Loading lib_com/bitstream.c +217 −5 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ int16_t total_num_id = 0; FILE *FEC_pattern = NULL; /* FEC pattern file (for simulation of FEC) */ #endif #ifndef IND_LIST_DYN /*-------------------------------------------------------------------* * pack_bit() * Loading Loading @@ -119,6 +120,7 @@ static Word16 unpack_bit( return bit; } #endif /*-------------------------------------------------------------------* * rate2AMRWB_IOmode() Loading Loading @@ -241,6 +243,9 @@ ivas_error push_indice( ) { int16_t i; #ifdef IND_LIST_DYN int16_t j; #endif ivas_error error; error = IVAS_ERR_OK; Loading Loading @@ -271,8 +276,35 @@ ivas_error push_indice( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d exceeds the total number of indices: %d (frame %d) !\n", id, MAX_NUM_INDICES, frame ); } #ifdef IND_LIST_DYN /* check, if max number of indices has not been exceeded */ if ( hBstr->nb_ind_tot >= MAX_NUM_INDICES ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Maximum number of indices %d has been exceeded (frame %d) !\n", MAX_NUM_INDICES, frame ); } #endif #endif #ifdef IND_LIST_DYN /* find the location in the list of indices */ i = hBstr->nb_ind_tot; while ( i > 0 && id < hBstr->ind_list[i - 1].id ) { i--; } /* shift indices, if the new id is to be written somewhere inside the list */ if ( i < hBstr->nb_ind_tot ) { for ( j = hBstr->nb_ind_tot; j > i; j-- ) { hBstr->ind_list[j].id = hBstr->ind_list[j - 1].id; hBstr->ind_list[j].nb_bits = hBstr->ind_list[j - 1].nb_bits; hBstr->ind_list[j].value = hBstr->ind_list[j - 1].value; } } #else if ( hBstr->last_ind == id ) { /* indice with the same name as the previous one */ Loading @@ -287,20 +319,31 @@ ivas_error push_indice( i++; } } #endif #ifndef IND_LIST_DYN #ifdef DEBUGGING if ( hBstr->ind_list[i].nb_bits > 0 ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d with value %d is trying to re-write an existing indice (frame %d) !\n", id, value, frame ); } #endif #endif /* store the new indice in the list */ #ifdef IND_LIST_DYN hBstr->ind_list[i].id = id; #endif hBstr->ind_list[i].value = value; hBstr->ind_list[i].nb_bits = nb_bits; /* updates */ #ifdef IND_LIST_DYN hBstr->nb_ind_tot++; hBstr->next_ind++; #else hBstr->next_ind = i + 1; #endif hBstr->last_ind = id; hBstr->nb_bits_tot += nb_bits; Loading Loading @@ -333,6 +376,9 @@ ivas_error push_next_indice( #endif ) { #ifdef IND_LIST_DYN int16_t prev_id; #endif ivas_error error; error = IVAS_ERR_OK; Loading @@ -356,20 +402,47 @@ ivas_error push_next_indice( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Total number of indices exceeded: %d !\n", MAX_NUM_INDICES ); } #ifndef IND_LIST_DYN if ( hBstr->ind_list[hBstr->next_ind].nb_bits > 0 ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice with value %d is trying to re-write an existing indice (frame %d) !\n", value, frame ); } #endif #endif #ifdef IND_LIST_DYN /* get the id of the previous indice -> it will be re-used */ if ( hBstr->nb_ind_tot > 0 ) { prev_id = hBstr->ind_list[hBstr->nb_ind_tot - 1].id; } else { prev_id = 0; } #endif /* store the values in the list */ hBstr->ind_list[hBstr->next_ind].value = value; hBstr->ind_list[hBstr->next_ind].nb_bits = nb_bits; #ifdef IND_LIST_DYN hBstr->ind_list[hBstr->nb_ind_tot].id = prev_id; #endif hBstr->ind_list[hBstr->nb_ind_tot].value = value; hBstr->ind_list[hBstr->nb_ind_tot].nb_bits = nb_bits; /* updates */ #ifdef IND_LIST_DYN hBstr->nb_ind_tot++; hBstr->next_ind = hBstr->nb_ind_tot; #else hBstr->next_ind++; #endif /* update the total number of bits already written */ hBstr->nb_bits_tot += nb_bits; #ifdef DEBUG_IND dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" ); total_num_id++; #endif return error; } Loading Loading @@ -398,10 +471,27 @@ void push_next_bits( uint16_t code; int16_t i, nb_bits_m15; Indice *ptr; #ifdef IND_LIST_DYN int16_t prev_id; #endif #ifdef DEBUG_BS_READ_WRITE printf( "%s: %d: %d\n", func, line, nb_bits ); #endif #ifdef IND_LIST_DYN ptr = &hBstr->ind_list[hBstr->nb_ind_tot]; /* get the id of the previous indice -> will be re-used here as well */ if ( hBstr->nb_ind_tot > 0 ) { prev_id = hBstr->ind_list[hBstr->nb_ind_tot - 1].id; } else { prev_id = 0; } #else ptr = &hBstr->ind_list[hBstr->next_ind]; #endif nb_bits_m15 = nb_bits - 15; for ( i = 0; i < nb_bits_m15; i += 16 ) Loading @@ -413,8 +503,18 @@ void push_next_bits( printf( "code: %d\n", code ); #endif ptr->nb_bits = 16; #ifdef IND_LIST_DYN ptr->id = prev_id; hBstr->nb_ind_tot++; #endif ++ptr; #ifdef DEBUG_IND dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" ); total_num_id++; #endif } for ( ; i < nb_bits; ++i ) { ptr->value = bits[i]; Loading @@ -422,15 +522,104 @@ void push_next_bits( printf( "value: %d\n", ptr->value ); #endif ptr->nb_bits = 1; #ifdef IND_LIST_DYN ptr->id = prev_id; hBstr->nb_ind_tot++; #endif ++ptr; #ifdef DEBUG_IND dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" ); total_num_id++; #endif } hBstr->next_ind = (int16_t) ( ptr - hBstr->ind_list ); hBstr->nb_bits_tot = hBstr->nb_bits_tot + nb_bits; return; } #ifdef IND_LIST_DYN /*-------------------------------------------------------------------* * find_indice() * * Find indice based on its id *-------------------------------------------------------------------*/ /*! r: result: index of the indice in the list, -1 if not found */ int16_t find_indice( BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ int16_t id, /* i : ID of the indice */ uint16_t *value, /* o : value of the quantized indice */ int16_t *nb_bits /* o : number of bits used to quantize the indice */ ) { int16_t i; for ( i = 0; i < hBstr->nb_ind_tot; i++ ) { if ( hBstr->ind_list[i].id == id && hBstr->ind_list[i].nb_bits > 0 ) { *value = hBstr->ind_list[i].value; *nb_bits = hBstr->ind_list[i].nb_bits; return i; } } return -1; } /*-------------------------------------------------------------------* * delete_indice() * * Delete indice based on its id (note, that nb_ind_tot and nb_bits_tot are updated) *-------------------------------------------------------------------*/ /*! r: number of deleted indices */ uint16_t delete_indice( BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ int16_t id /* i : ID of the indice */ ) { int16_t i, j; j = 0; for ( i = 0; i < hBstr->nb_ind_tot; i++ ) { if ( hBstr->ind_list[i].id == id ) { hBstr->nb_bits_tot -= hBstr->ind_list[i].nb_bits; continue; } if ( j < i ) { /* shift the indice left */ hBstr->ind_list[j].id = hBstr->ind_list[i].id; hBstr->ind_list[j].value = hBstr->ind_list[i].value; hBstr->ind_list[j].nb_bits = hBstr->ind_list[i].nb_bits; } j++; } hBstr->nb_ind_tot = j; hBstr->next_ind = j; for ( ; j < i; j++ ) { /* reset the shifted indices at the end of the list */ hBstr->ind_list[j].nb_bits = -1; } return i - j; } #endif /*-------------------------------------------------------------------* * get_next_indice() * Loading Loading @@ -647,6 +836,9 @@ void reset_indices_enc( int16_t i; hBstr->nb_bits_tot = 0; #ifdef IND_LIST_DYN hBstr->nb_ind_tot = 0; #endif hBstr->next_ind = 0; hBstr->last_ind = -1; Loading Loading @@ -679,7 +871,11 @@ void reset_indices_dec( *-------------------------------------------------------------------*/ static int16_t write_indices_to_stream( #ifdef IND_LIST_DYN Indice *ind_list, #else Indice *ind_list_metadata, #endif uint16_t **pt_stream, const int16_t inc, const int16_t num_indices ) Loading @@ -693,8 +889,13 @@ static int16_t write_indices_to_stream( for ( i = 0; i < num_indices; i++ ) { #ifdef IND_LIST_DYN value = ind_list[i].value; nb_bits = ind_list[i].nb_bits; #else value = ind_list_metadata[i].value; nb_bits = ind_list_metadata[i].nb_bits; #endif if ( nb_bits > 0 ) { Loading Loading @@ -726,6 +927,10 @@ static int16_t write_indices_to_stream( { /* fprintf( stderr, "Warning: %s: nb_bits == 0!\n", __func__ ); */ } else { /* fprintf( stderr, "Warning: %s: nb_bits == %d!\n", __func__, nb_bits ); */ } #endif } #ifdef ENABLE_BITRATE_VERIFICATION Loading Loading @@ -851,7 +1056,13 @@ static ivas_error write_indices_element( #ifdef ENABLE_BITRATE_VERIFICATION total_nb_bits = #endif write_indices_to_stream( sts[n]->hBstr->ind_list, &pt_stream_loc, 1, MAX_NUM_INDICES ); write_indices_to_stream( sts[n]->hBstr->ind_list, &pt_stream_loc, 1, #ifdef IND_LIST_DYN sts[n]->hBstr->nb_ind_tot #else MAX_NUM_INDICES #endif ); #ifdef ENABLE_BITRATE_VERIFICATION if ( total_nb_bits != sts[n]->hBstr->nb_bits_tot ) Loading Loading @@ -984,7 +1195,7 @@ ivas_error write_indices_ivas( return error; } #ifndef IND_LIST_DYN /*-------------------------------------------------------------------* * indices_to_serial_generic() * Loading Loading @@ -1034,6 +1245,7 @@ void indices_to_serial_generic( return; } #endif /*---------------------------------------------------------------------* * convertSerialToBytestream( ) Loading lib_com/prot.h +17 −1 Original line number Diff line number Diff line Loading @@ -515,6 +515,21 @@ void push_next_bits( #endif ); #ifdef IND_LIST_DYN int16_t find_indice( /* o : index of the indice in the list, -1 if not found */ BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ int16_t id, /* i : ID of the indice */ uint16_t *value, /* o : value of the quantized indice */ int16_t *nb_bits /* o : number of bits used to quantize the indice */ ); uint16_t delete_indice( /* o : number of deleted indices */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ int16_t id /* i : ID of the indice */ ); #endif /*! r: value of the indice */ #ifdef DEBUG_BS_READ_WRITE #define get_next_indice( ... ) get_next_indice_( __VA_ARGS__, __LINE__, __func__ ) Loading Loading @@ -612,13 +627,14 @@ Decoder_State **reset_elements( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #ifndef IND_LIST_DYN 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 /* o : size of the binary encoded access unit [bits] */ ); #endif void convertSerialToBytestream( const uint16_t *const serial, /* i : input serial bitstream with values 0 and 1 */ Loading lib_enc/acelp_core_switch_enc.c +17 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ void acelp_core_switch_enc( const float *inp; int32_t cbrate; float Aq[2 * ( M + 1 )]; #ifdef IND_LIST_DYN uint16_t value; int16_t nb_bits; #endif BSTR_ENC_HANDLE hBstr = st->hBstr; /* initializations */ Loading Loading @@ -159,12 +163,25 @@ void acelp_core_switch_enc( * Manipulate ACELP subframe indices (move them to their proper place) *----------------------------------------------------------------*/ #ifdef IND_LIST_DYN i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); #ifdef DEBUGGING assert( i >= 0 && "Internal error in ACELP core switching - unable to find ACELP subframe indices!" ); #endif while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START ) { push_indice( hBstr, IND_CORE_SWITCHING_CELP_SUBFRAME, hBstr->ind_list[i].value, hBstr->ind_list[i].nb_bits ); i++; } delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); #else for ( i = 0; i < 20; i++ ) { hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits; hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; } #endif /*----------------------------------------------------------------* * BWE encoding Loading lib_enc/cng_enc.c +8 −0 Original line number Diff line number Diff line Loading @@ -885,8 +885,12 @@ void swb_CNG_enc( else if ( st->element_mode == IVAS_CPE_DFT && st->core_brate == SID_2k40 ) { /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ #ifdef IND_LIST_DYN delete_indice( st->hBstr, IND_CNG_ENV1 ); #else st->hBstr->nb_bits_tot = st->hBstr->nb_bits_tot - st->hBstr->ind_list[IND_CNG_ENV1].nb_bits; st->hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; #endif push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); push_indice( st->hBstr, IND_UNUSED, 0, 4 ); push_indice( st->hBstr, IND_SID_BW, 1, 1 ); Loading Loading @@ -962,8 +966,12 @@ static void shb_CNG_encod( push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 ); push_indice( hBstr, IND_SID_BW, 1, 1 ); #ifdef IND_LIST_DYN delete_indice( hBstr, IND_CNG_ENV1 ); #else hBstr->nb_bits_tot = hBstr->nb_bits_tot - hBstr->ind_list[IND_CNG_ENV1].nb_bits; hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; #endif if ( st->element_mode == IVAS_CPE_DFT ) { push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); Loading Loading
apps/encoder.c +3 −3 Original line number Diff line number Diff line Loading @@ -720,9 +720,9 @@ int main( #ifdef DEBUG_IND { int16_t tmp_i = -1; dbgwrite( &tmp_i, sizeof( int16_t ), 1, 960 - total_num_id, "res/ind_list.x" ); //int16_t tmp_i = -1; //dbgwrite( &tmp_i, sizeof( int16_t ), 1, 960 - total_num_id, "res/ind_list.x" ); dbgwrite( &total_num_id, sizeof( int16_t ), 1, 1, "res/ind_total_num.x" ); } #endif Loading
lib_com/bitstream.c +217 −5 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ int16_t total_num_id = 0; FILE *FEC_pattern = NULL; /* FEC pattern file (for simulation of FEC) */ #endif #ifndef IND_LIST_DYN /*-------------------------------------------------------------------* * pack_bit() * Loading Loading @@ -119,6 +120,7 @@ static Word16 unpack_bit( return bit; } #endif /*-------------------------------------------------------------------* * rate2AMRWB_IOmode() Loading Loading @@ -241,6 +243,9 @@ ivas_error push_indice( ) { int16_t i; #ifdef IND_LIST_DYN int16_t j; #endif ivas_error error; error = IVAS_ERR_OK; Loading Loading @@ -271,8 +276,35 @@ ivas_error push_indice( { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d exceeds the total number of indices: %d (frame %d) !\n", id, MAX_NUM_INDICES, frame ); } #ifdef IND_LIST_DYN /* check, if max number of indices has not been exceeded */ if ( hBstr->nb_ind_tot >= MAX_NUM_INDICES ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Maximum number of indices %d has been exceeded (frame %d) !\n", MAX_NUM_INDICES, frame ); } #endif #endif #ifdef IND_LIST_DYN /* find the location in the list of indices */ i = hBstr->nb_ind_tot; while ( i > 0 && id < hBstr->ind_list[i - 1].id ) { i--; } /* shift indices, if the new id is to be written somewhere inside the list */ if ( i < hBstr->nb_ind_tot ) { for ( j = hBstr->nb_ind_tot; j > i; j-- ) { hBstr->ind_list[j].id = hBstr->ind_list[j - 1].id; hBstr->ind_list[j].nb_bits = hBstr->ind_list[j - 1].nb_bits; hBstr->ind_list[j].value = hBstr->ind_list[j - 1].value; } } #else if ( hBstr->last_ind == id ) { /* indice with the same name as the previous one */ Loading @@ -287,20 +319,31 @@ ivas_error push_indice( i++; } } #endif #ifndef IND_LIST_DYN #ifdef DEBUGGING if ( hBstr->ind_list[i].nb_bits > 0 ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice ID = %d with value %d is trying to re-write an existing indice (frame %d) !\n", id, value, frame ); } #endif #endif /* store the new indice in the list */ #ifdef IND_LIST_DYN hBstr->ind_list[i].id = id; #endif hBstr->ind_list[i].value = value; hBstr->ind_list[i].nb_bits = nb_bits; /* updates */ #ifdef IND_LIST_DYN hBstr->nb_ind_tot++; hBstr->next_ind++; #else hBstr->next_ind = i + 1; #endif hBstr->last_ind = id; hBstr->nb_bits_tot += nb_bits; Loading Loading @@ -333,6 +376,9 @@ ivas_error push_next_indice( #endif ) { #ifdef IND_LIST_DYN int16_t prev_id; #endif ivas_error error; error = IVAS_ERR_OK; Loading @@ -356,20 +402,47 @@ ivas_error push_next_indice( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Total number of indices exceeded: %d !\n", MAX_NUM_INDICES ); } #ifndef IND_LIST_DYN if ( hBstr->ind_list[hBstr->next_ind].nb_bits > 0 ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Indice with value %d is trying to re-write an existing indice (frame %d) !\n", value, frame ); } #endif #endif #ifdef IND_LIST_DYN /* get the id of the previous indice -> it will be re-used */ if ( hBstr->nb_ind_tot > 0 ) { prev_id = hBstr->ind_list[hBstr->nb_ind_tot - 1].id; } else { prev_id = 0; } #endif /* store the values in the list */ hBstr->ind_list[hBstr->next_ind].value = value; hBstr->ind_list[hBstr->next_ind].nb_bits = nb_bits; #ifdef IND_LIST_DYN hBstr->ind_list[hBstr->nb_ind_tot].id = prev_id; #endif hBstr->ind_list[hBstr->nb_ind_tot].value = value; hBstr->ind_list[hBstr->nb_ind_tot].nb_bits = nb_bits; /* updates */ #ifdef IND_LIST_DYN hBstr->nb_ind_tot++; hBstr->next_ind = hBstr->nb_ind_tot; #else hBstr->next_ind++; #endif /* update the total number of bits already written */ hBstr->nb_bits_tot += nb_bits; #ifdef DEBUG_IND dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" ); total_num_id++; #endif return error; } Loading Loading @@ -398,10 +471,27 @@ void push_next_bits( uint16_t code; int16_t i, nb_bits_m15; Indice *ptr; #ifdef IND_LIST_DYN int16_t prev_id; #endif #ifdef DEBUG_BS_READ_WRITE printf( "%s: %d: %d\n", func, line, nb_bits ); #endif #ifdef IND_LIST_DYN ptr = &hBstr->ind_list[hBstr->nb_ind_tot]; /* get the id of the previous indice -> will be re-used here as well */ if ( hBstr->nb_ind_tot > 0 ) { prev_id = hBstr->ind_list[hBstr->nb_ind_tot - 1].id; } else { prev_id = 0; } #else ptr = &hBstr->ind_list[hBstr->next_ind]; #endif nb_bits_m15 = nb_bits - 15; for ( i = 0; i < nb_bits_m15; i += 16 ) Loading @@ -413,8 +503,18 @@ void push_next_bits( printf( "code: %d\n", code ); #endif ptr->nb_bits = 16; #ifdef IND_LIST_DYN ptr->id = prev_id; hBstr->nb_ind_tot++; #endif ++ptr; #ifdef DEBUG_IND dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" ); total_num_id++; #endif } for ( ; i < nb_bits; ++i ) { ptr->value = bits[i]; Loading @@ -422,15 +522,104 @@ void push_next_bits( printf( "value: %d\n", ptr->value ); #endif ptr->nb_bits = 1; #ifdef IND_LIST_DYN ptr->id = prev_id; hBstr->nb_ind_tot++; #endif ++ptr; #ifdef DEBUG_IND dbgwrite( &hBstr->last_ind, sizeof( int16_t ), 1, 1, "res/ind_list.x" ); total_num_id++; #endif } hBstr->next_ind = (int16_t) ( ptr - hBstr->ind_list ); hBstr->nb_bits_tot = hBstr->nb_bits_tot + nb_bits; return; } #ifdef IND_LIST_DYN /*-------------------------------------------------------------------* * find_indice() * * Find indice based on its id *-------------------------------------------------------------------*/ /*! r: result: index of the indice in the list, -1 if not found */ int16_t find_indice( BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ int16_t id, /* i : ID of the indice */ uint16_t *value, /* o : value of the quantized indice */ int16_t *nb_bits /* o : number of bits used to quantize the indice */ ) { int16_t i; for ( i = 0; i < hBstr->nb_ind_tot; i++ ) { if ( hBstr->ind_list[i].id == id && hBstr->ind_list[i].nb_bits > 0 ) { *value = hBstr->ind_list[i].value; *nb_bits = hBstr->ind_list[i].nb_bits; return i; } } return -1; } /*-------------------------------------------------------------------* * delete_indice() * * Delete indice based on its id (note, that nb_ind_tot and nb_bits_tot are updated) *-------------------------------------------------------------------*/ /*! r: number of deleted indices */ uint16_t delete_indice( BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ int16_t id /* i : ID of the indice */ ) { int16_t i, j; j = 0; for ( i = 0; i < hBstr->nb_ind_tot; i++ ) { if ( hBstr->ind_list[i].id == id ) { hBstr->nb_bits_tot -= hBstr->ind_list[i].nb_bits; continue; } if ( j < i ) { /* shift the indice left */ hBstr->ind_list[j].id = hBstr->ind_list[i].id; hBstr->ind_list[j].value = hBstr->ind_list[i].value; hBstr->ind_list[j].nb_bits = hBstr->ind_list[i].nb_bits; } j++; } hBstr->nb_ind_tot = j; hBstr->next_ind = j; for ( ; j < i; j++ ) { /* reset the shifted indices at the end of the list */ hBstr->ind_list[j].nb_bits = -1; } return i - j; } #endif /*-------------------------------------------------------------------* * get_next_indice() * Loading Loading @@ -647,6 +836,9 @@ void reset_indices_enc( int16_t i; hBstr->nb_bits_tot = 0; #ifdef IND_LIST_DYN hBstr->nb_ind_tot = 0; #endif hBstr->next_ind = 0; hBstr->last_ind = -1; Loading Loading @@ -679,7 +871,11 @@ void reset_indices_dec( *-------------------------------------------------------------------*/ static int16_t write_indices_to_stream( #ifdef IND_LIST_DYN Indice *ind_list, #else Indice *ind_list_metadata, #endif uint16_t **pt_stream, const int16_t inc, const int16_t num_indices ) Loading @@ -693,8 +889,13 @@ static int16_t write_indices_to_stream( for ( i = 0; i < num_indices; i++ ) { #ifdef IND_LIST_DYN value = ind_list[i].value; nb_bits = ind_list[i].nb_bits; #else value = ind_list_metadata[i].value; nb_bits = ind_list_metadata[i].nb_bits; #endif if ( nb_bits > 0 ) { Loading Loading @@ -726,6 +927,10 @@ static int16_t write_indices_to_stream( { /* fprintf( stderr, "Warning: %s: nb_bits == 0!\n", __func__ ); */ } else { /* fprintf( stderr, "Warning: %s: nb_bits == %d!\n", __func__, nb_bits ); */ } #endif } #ifdef ENABLE_BITRATE_VERIFICATION Loading Loading @@ -851,7 +1056,13 @@ static ivas_error write_indices_element( #ifdef ENABLE_BITRATE_VERIFICATION total_nb_bits = #endif write_indices_to_stream( sts[n]->hBstr->ind_list, &pt_stream_loc, 1, MAX_NUM_INDICES ); write_indices_to_stream( sts[n]->hBstr->ind_list, &pt_stream_loc, 1, #ifdef IND_LIST_DYN sts[n]->hBstr->nb_ind_tot #else MAX_NUM_INDICES #endif ); #ifdef ENABLE_BITRATE_VERIFICATION if ( total_nb_bits != sts[n]->hBstr->nb_bits_tot ) Loading Loading @@ -984,7 +1195,7 @@ ivas_error write_indices_ivas( return error; } #ifndef IND_LIST_DYN /*-------------------------------------------------------------------* * indices_to_serial_generic() * Loading Loading @@ -1034,6 +1245,7 @@ void indices_to_serial_generic( return; } #endif /*---------------------------------------------------------------------* * convertSerialToBytestream( ) Loading
lib_com/prot.h +17 −1 Original line number Diff line number Diff line Loading @@ -515,6 +515,21 @@ void push_next_bits( #endif ); #ifdef IND_LIST_DYN int16_t find_indice( /* o : index of the indice in the list, -1 if not found */ BSTR_ENC_HANDLE hBstr, /* i : encoder bitstream handle */ int16_t id, /* i : ID of the indice */ uint16_t *value, /* o : value of the quantized indice */ int16_t *nb_bits /* o : number of bits used to quantize the indice */ ); uint16_t delete_indice( /* o : number of deleted indices */ BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ int16_t id /* i : ID of the indice */ ); #endif /*! r: value of the indice */ #ifdef DEBUG_BS_READ_WRITE #define get_next_indice( ... ) get_next_indice_( __VA_ARGS__, __LINE__, __func__ ) Loading Loading @@ -612,13 +627,14 @@ Decoder_State **reset_elements( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); #ifndef IND_LIST_DYN 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 /* o : size of the binary encoded access unit [bits] */ ); #endif void convertSerialToBytestream( const uint16_t *const serial, /* i : input serial bitstream with values 0 and 1 */ Loading
lib_enc/acelp_core_switch_enc.c +17 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,10 @@ void acelp_core_switch_enc( const float *inp; int32_t cbrate; float Aq[2 * ( M + 1 )]; #ifdef IND_LIST_DYN uint16_t value; int16_t nb_bits; #endif BSTR_ENC_HANDLE hBstr = st->hBstr; /* initializations */ Loading Loading @@ -159,12 +163,25 @@ void acelp_core_switch_enc( * Manipulate ACELP subframe indices (move them to their proper place) *----------------------------------------------------------------*/ #ifdef IND_LIST_DYN i = find_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START, &value, &nb_bits ); #ifdef DEBUGGING assert( i >= 0 && "Internal error in ACELP core switching - unable to find ACELP subframe indices!" ); #endif while ( hBstr->ind_list[i].id == TAG_ACELP_SUBFR_LOOP_START ) { push_indice( hBstr, IND_CORE_SWITCHING_CELP_SUBFRAME, hBstr->ind_list[i].value, hBstr->ind_list[i].nb_bits ); i++; } delete_indice( hBstr, TAG_ACELP_SUBFR_LOOP_START ); #else for ( i = 0; i < 20; i++ ) { hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].value = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].value; hBstr->ind_list[IND_CORE_SWITCHING_CELP_SUBFRAME + i].nb_bits = hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits; hBstr->ind_list[TAG_ACELP_SUBFR_LOOP_START + i].nb_bits = -1; } #endif /*----------------------------------------------------------------* * BWE encoding Loading
lib_enc/cng_enc.c +8 −0 Original line number Diff line number Diff line Loading @@ -885,8 +885,12 @@ void swb_CNG_enc( else if ( st->element_mode == IVAS_CPE_DFT && st->core_brate == SID_2k40 ) { /* LF-boost not used in DFT-stereo, instead the bandwidth is transmitted */ #ifdef IND_LIST_DYN delete_indice( st->hBstr, IND_CNG_ENV1 ); #else st->hBstr->nb_bits_tot = st->hBstr->nb_bits_tot - st->hBstr->ind_list[IND_CNG_ENV1].nb_bits; st->hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; #endif push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); push_indice( st->hBstr, IND_UNUSED, 0, 4 ); push_indice( st->hBstr, IND_SID_BW, 1, 1 ); Loading Loading @@ -962,8 +966,12 @@ static void shb_CNG_encod( push_indice( hBstr, IND_SHB_CNG_GAIN, idx_ener, 4 ); push_indice( hBstr, IND_SID_BW, 1, 1 ); #ifdef IND_LIST_DYN delete_indice( hBstr, IND_CNG_ENV1 ); #else hBstr->nb_bits_tot = hBstr->nb_bits_tot - hBstr->ind_list[IND_CNG_ENV1].nb_bits; hBstr->ind_list[IND_CNG_ENV1].nb_bits = -1; #endif if ( st->element_mode == IVAS_CPE_DFT ) { push_indice( st->hBstr, IND_BWIDTH, st->bwidth, 2 ); Loading