Loading lib_com/bitstream.c +158 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,164 @@ Word16 rate2EVSmode( return rate2AMRWB_IOmode( brate ); } #ifdef IND_LIST_DYN /*-------------------------------------------------------------------* * ind_list_realloc() * * Re-allocate list of indices if the maximum number of allowed indices has changed *-------------------------------------------------------------------*/ ivas_error ind_list_realloc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ) { int16_t i, max_num_indices; INDICE_HANDLE new_ind_list; /* get the maximum allowed number of indices in the list */ max_num_indices = set_max_num_indices( ivas_format, total_brate ); /* check, if the maximum number of allowed indices has changed */ if ( max_num_indices != hBstr->max_num_indices ) { /* allocate new buffer of indices */ if ( ( new_ind_list = (INDICE_HANDLE) malloc( max_num_indices * sizeof( Indice ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) ); } /* move indices from the old list to the new list */ i = 0; while ( hBstr->ind_list[i].nb_bits > 0 ) { new_ind_list[i].id = hBstr->ind_list[i].id; new_ind_list[i].value = hBstr->ind_list[i].value; new_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits; i++; } /* reset nb_bits of all other indices to -1 */ for ( ; i < max_num_indices; i++ ) { new_ind_list[i].nb_bits = -1; } /* free the old list */ free( hBstr->ind_list ); /* set pointer to the new list */ hBstr->ind_list = new_ind_list; /* set the new maximum for the allowed number of indices */ hBstr->max_num_indices = max_num_indices; } return IVAS_ERR_OK; } #ifdef IND_LIST_DYN /*-----------------------------------------------------------------------* * set_max_num_indices() * * Set the maximum allowed number of indices in the list *-----------------------------------------------------------------------*/ int16_t set_max_num_indices( /* o : maximum number of indices */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ) { /* set the maximum required number of indices */ if ( ivas_format == MONO_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 450; } else { return 450; } } else if ( ivas_format == STEREO_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_128k ) { return 450; } else { return 550; } } else if ( ivas_format == ISM_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_128k ) { return 450; } else { return 700; } } else if ( ivas_format == SBA_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_128k ) { return 450; } else { return 700; } } else if ( ivas_format == MASA_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_160k ) { return 450; } else { return 700; } } else if ( ivas_format == MC_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 450; } else { return 1050; } } return 1050; } #endif #endif /*-------------------------------------------------------------------* * push_indice() * Loading lib_com/ivas_cnst.h +3 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,9 @@ typedef enum #define MAX_BITS_METADATA 2640 /* max. bit-budget of metadata, one channel */ /* IVAS_fmToDo: to be confirmed for final value once mature */ #define MAX_NUM_METADATA max( 2, MAX_NUM_OBJECTS ) /* number of max. metadata (now only 2 for DirAC) */ #ifdef IND_LIST_DYN #define MAX_NUM_IND_TEMP_LIST 10 /* maximum number of indices in the temporary list */ #endif #define IVAS_ENC_DELAY_NS ACELP_LOOK_NS #define IVAS_DEC_DELAY_NS 3250000L /* 3.25 ms: IVAS decoder delay (without renderer delay) */ Loading lib_com/ivas_prot.h +3 −0 Original line number Diff line number Diff line Loading @@ -1979,6 +1979,9 @@ void InternalTCXDecoder( void stereo_mdct_core_enc( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ #ifdef IND_LIST_DYN const int16_t ivas_format, /* i : IVAS format */ #endif float new_samples[CPE_CHANNELS][L_INP], /* i : new samples */ float old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ float pitch_buf[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */ Loading lib_com/prot.h +11 −0 Original line number Diff line number Diff line Loading @@ -516,6 +516,17 @@ void push_next_bits( ); #ifdef IND_LIST_DYN int16_t set_max_num_indices( /* o : maximum number of indices */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ); ivas_error ind_list_realloc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ); 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 */ Loading lib_enc/init_enc.c +4 −79 Original line number Diff line number Diff line Loading @@ -116,85 +116,8 @@ ivas_error init_encoder( } #ifdef IND_LIST_DYN /* set the maximum required number of indices */ if ( hEncoderConfig->ivas_format == MONO_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 450; } else { st->hBstr->max_num_indices = 450; } } else if ( hEncoderConfig->ivas_format == STEREO_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 240; } else { st->hBstr->max_num_indices = 350; } } else if ( hEncoderConfig->ivas_format == ISM_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 150; } else { st->hBstr->max_num_indices = 350; } } else if ( hEncoderConfig->ivas_format == SBA_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 250; } else if ( st->total_brate < IVAS_128k ) { st->hBstr->max_num_indices = 450; } else { st->hBstr->max_num_indices = 700; } } else if ( hEncoderConfig->ivas_format == MASA_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 250; } else if ( st->total_brate < IVAS_160k ) { st->hBstr->max_num_indices = 450; } else { st->hBstr->max_num_indices = 700; } } else if ( hEncoderConfig->ivas_format == MC_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 550; } else { st->hBstr->max_num_indices = 1050; } } else { st->hBstr->max_num_indices = 1050; } /* set the maximum allowed number of indices in the list */ st->hBstr->max_num_indices = set_max_num_indices( hEncoderConfig->ivas_format, st->total_brate ); /* allocate buffer of indices */ if ( ( st->hBstr->ind_list = (INDICE_HANDLE) malloc( st->hBstr->max_num_indices * sizeof( Indice ) ) ) == NULL ) Loading Loading @@ -928,6 +851,8 @@ ivas_error init_encoder( } /*-----------------------------------------------------------------------* * LPDmem_enc_init() * Loading Loading
lib_com/bitstream.c +158 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,164 @@ Word16 rate2EVSmode( return rate2AMRWB_IOmode( brate ); } #ifdef IND_LIST_DYN /*-------------------------------------------------------------------* * ind_list_realloc() * * Re-allocate list of indices if the maximum number of allowed indices has changed *-------------------------------------------------------------------*/ ivas_error ind_list_realloc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ) { int16_t i, max_num_indices; INDICE_HANDLE new_ind_list; /* get the maximum allowed number of indices in the list */ max_num_indices = set_max_num_indices( ivas_format, total_brate ); /* check, if the maximum number of allowed indices has changed */ if ( max_num_indices != hBstr->max_num_indices ) { /* allocate new buffer of indices */ if ( ( new_ind_list = (INDICE_HANDLE) malloc( max_num_indices * sizeof( Indice ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for buffer of indices!\n" ) ); } /* move indices from the old list to the new list */ i = 0; while ( hBstr->ind_list[i].nb_bits > 0 ) { new_ind_list[i].id = hBstr->ind_list[i].id; new_ind_list[i].value = hBstr->ind_list[i].value; new_ind_list[i].nb_bits = hBstr->ind_list[i].nb_bits; i++; } /* reset nb_bits of all other indices to -1 */ for ( ; i < max_num_indices; i++ ) { new_ind_list[i].nb_bits = -1; } /* free the old list */ free( hBstr->ind_list ); /* set pointer to the new list */ hBstr->ind_list = new_ind_list; /* set the new maximum for the allowed number of indices */ hBstr->max_num_indices = max_num_indices; } return IVAS_ERR_OK; } #ifdef IND_LIST_DYN /*-----------------------------------------------------------------------* * set_max_num_indices() * * Set the maximum allowed number of indices in the list *-----------------------------------------------------------------------*/ int16_t set_max_num_indices( /* o : maximum number of indices */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ) { /* set the maximum required number of indices */ if ( ivas_format == MONO_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 450; } else { return 450; } } else if ( ivas_format == STEREO_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_128k ) { return 450; } else { return 550; } } else if ( ivas_format == ISM_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_128k ) { return 450; } else { return 700; } } else if ( ivas_format == SBA_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_128k ) { return 450; } else { return 700; } } else if ( ivas_format == MASA_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 250; } else if ( total_brate < IVAS_160k ) { return 450; } else { return 700; } } else if ( ivas_format == MC_FORMAT ) { if ( total_brate < IVAS_24k4 ) { return 450; } else { return 1050; } } return 1050; } #endif #endif /*-------------------------------------------------------------------* * push_indice() * Loading
lib_com/ivas_cnst.h +3 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,9 @@ typedef enum #define MAX_BITS_METADATA 2640 /* max. bit-budget of metadata, one channel */ /* IVAS_fmToDo: to be confirmed for final value once mature */ #define MAX_NUM_METADATA max( 2, MAX_NUM_OBJECTS ) /* number of max. metadata (now only 2 for DirAC) */ #ifdef IND_LIST_DYN #define MAX_NUM_IND_TEMP_LIST 10 /* maximum number of indices in the temporary list */ #endif #define IVAS_ENC_DELAY_NS ACELP_LOOK_NS #define IVAS_DEC_DELAY_NS 3250000L /* 3.25 ms: IVAS decoder delay (without renderer delay) */ Loading
lib_com/ivas_prot.h +3 −0 Original line number Diff line number Diff line Loading @@ -1979,6 +1979,9 @@ void InternalTCXDecoder( void stereo_mdct_core_enc( CPE_ENC_HANDLE hCPE, /* i/o: CPE encoder structure */ #ifdef IND_LIST_DYN const int16_t ivas_format, /* i : IVAS format */ #endif float new_samples[CPE_CHANNELS][L_INP], /* i : new samples */ float old_wsp[CPE_CHANNELS][L_WSP], /* i : 12.8kHz weighted speech (for LTP */ float pitch_buf[CPE_CHANNELS][NB_SUBFR16k] /* o : floating pitch for each subframe */ Loading
lib_com/prot.h +11 −0 Original line number Diff line number Diff line Loading @@ -516,6 +516,17 @@ void push_next_bits( ); #ifdef IND_LIST_DYN int16_t set_max_num_indices( /* o : maximum number of indices */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ); ivas_error ind_list_realloc( BSTR_ENC_HANDLE hBstr, /* i/o: encoder bitstream handle */ const IVAS_FORMAT ivas_format, /* i : IVAS format */ const int32_t total_brate /* i : total bitrate */ ); 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 */ Loading
lib_enc/init_enc.c +4 −79 Original line number Diff line number Diff line Loading @@ -116,85 +116,8 @@ ivas_error init_encoder( } #ifdef IND_LIST_DYN /* set the maximum required number of indices */ if ( hEncoderConfig->ivas_format == MONO_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 450; } else { st->hBstr->max_num_indices = 450; } } else if ( hEncoderConfig->ivas_format == STEREO_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 240; } else { st->hBstr->max_num_indices = 350; } } else if ( hEncoderConfig->ivas_format == ISM_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 150; } else { st->hBstr->max_num_indices = 350; } } else if ( hEncoderConfig->ivas_format == SBA_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 250; } else if ( st->total_brate < IVAS_128k ) { st->hBstr->max_num_indices = 450; } else { st->hBstr->max_num_indices = 700; } } else if ( hEncoderConfig->ivas_format == MASA_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 250; } else if ( st->total_brate < IVAS_160k ) { st->hBstr->max_num_indices = 450; } else { st->hBstr->max_num_indices = 700; } } else if ( hEncoderConfig->ivas_format == MC_FORMAT ) { if ( st->total_brate < IVAS_24k4 ) { st->hBstr->max_num_indices = 550; } else { st->hBstr->max_num_indices = 1050; } } else { st->hBstr->max_num_indices = 1050; } /* set the maximum allowed number of indices in the list */ st->hBstr->max_num_indices = set_max_num_indices( hEncoderConfig->ivas_format, st->total_brate ); /* allocate buffer of indices */ if ( ( st->hBstr->ind_list = (INDICE_HANDLE) malloc( st->hBstr->max_num_indices * sizeof( Indice ) ) ) == NULL ) Loading Loading @@ -928,6 +851,8 @@ ivas_error init_encoder( } /*-----------------------------------------------------------------------* * LPDmem_enc_init() * Loading