diff options
author | Akshay Ragir <akshay.ragir@ittiam.com> | 2023-10-12 12:53:26 +0530 |
---|---|---|
committer | Divya B M <89966460+divya-bm@users.noreply.github.com> | 2023-10-12 19:24:54 +0530 |
commit | f29c4480db202f2712a285e2d608428430370bdf (patch) | |
tree | 14398dd659bc5be274c94685c6fc25f0ab1492f5 | |
parent | fcf3e9af7de03133c4d1be76555638dacac85347 (diff) | |
download | libxaac-f29c4480db202f2712a285e2d608428430370bdf.tar.gz |
Code refactoring and minor bug fixes
36 files changed, 147 insertions, 245 deletions
diff --git a/encoder/drc_src/impd_drc_api.c b/encoder/drc_src/impd_drc_api.c index fac98ff..4218903 100644 --- a/encoder/drc_src/impd_drc_api.c +++ b/encoder/drc_src/impd_drc_api.c @@ -248,14 +248,6 @@ IA_ERRORCODE impd_drc_enc_init(VOID *pstr_drc_state, VOID *ptr_drc_scratch, WORD32 bit_count = 0; ia_drc_enc_state *pstr_drc_state_local = pstr_drc_state; -#ifdef ENABLE_SET_JUMP - jmp_buf drc_enc_init_jmp_buf; - err_code = setjmp(drc_enc_init_jmp_buf); - if (err_code != IA_NO_ERROR) { - return IA_EXHEAACE_INIT_FATAL_DRC_INSUFFICIENT_WRITE_BUFFER_SIZE; - } -#endif // ENABLE_SET_JUMP - pstr_drc_state_local->drc_scratch_mem = ptr_drc_scratch; pstr_drc_state_local->drc_scratch_used = 0; @@ -275,13 +267,6 @@ IA_ERRORCODE impd_drc_enc_init(VOID *pstr_drc_state, VOID *ptr_drc_scratch, pstr_drc_state_local->bit_buf_base_out, sizeof(pstr_drc_state_local->bit_buf_base_out), 1); -#ifdef ENABLE_SET_JUMP - pstr_drc_state_local->str_bit_buf_cfg.impd_drc_jmp_buf = &drc_enc_init_jmp_buf; - pstr_drc_state_local->str_bit_buf_cfg_ext.impd_drc_jmp_buf = &drc_enc_init_jmp_buf; - pstr_drc_state_local->str_bit_buf_cfg_tmp.impd_drc_jmp_buf = &drc_enc_init_jmp_buf; - pstr_drc_state_local->str_bit_buf_out.impd_drc_jmp_buf = &drc_enc_init_jmp_buf; -#endif // ENABLE_SET_JUMP - err_code = impd_drc_validate_config_params(pstr_inp_config); if (err_code) { return err_code; diff --git a/encoder/iusace_enc_main.c b/encoder/iusace_enc_main.c index b24e9c8..fa2a0ac 100644 --- a/encoder/iusace_enc_main.c +++ b/encoder/iusace_enc_main.c @@ -507,7 +507,7 @@ WORD32 iusace_limitbitrate(WORD32 core_sample_rate, WORD32 frame_len, WORD32 num IA_ERRORCODE iusace_enc_init(ia_usac_encoder_config_struct *ptr_usac_config, ixheaace_audio_specific_config_struct *pstr_asc, ia_usac_data_struct *pstr_state) { - WORD32 err_code = 0; + IA_ERRORCODE err_code = IA_NO_ERROR; WORD32 i, j, k, idx, i_ch; UWORD32 elem_idx = 0; ia_usac_data_struct *usac_data = (pstr_state); @@ -625,7 +625,7 @@ IA_ERRORCODE iusace_enc_init(ia_usac_encoder_config_struct *ptr_usac_config, case ID_USAC_EXT: break; default: - return -1; + return IA_EXHEAACE_INIT_FATAL_USAC_INVALID_ELEMENT_TYPE; } } @@ -645,7 +645,7 @@ IA_ERRORCODE iusace_enc_init(ia_usac_encoder_config_struct *ptr_usac_config, case ID_USAC_EXT: break; default: - return -1; + return IA_EXHEAACE_INIT_FATAL_USAC_INVALID_ELEMENT_TYPE; } usac_data->str_qc_main.str_qc_data[ch_idx].num_ch = 1; @@ -774,12 +774,14 @@ IA_ERRORCODE iusace_enc_init(ia_usac_encoder_config_struct *ptr_usac_config, usac_data->pstr_tns_info[i_ch]->max_sfb_long = usac_data->str_psy_mod.str_psy_long_config[ch_idx].sfb_count; - if (iusace_tns_init(ptr_usac_config->core_sample_rate, + err_code = iusace_tns_init(ptr_usac_config->core_sample_rate, usac_data->str_qc_main.str_qc_data[ch_idx].ch_bitrate / usac_data->str_qc_main.str_qc_data[ch_idx].num_ch, usac_data->pstr_tns_info[i_ch], - usac_data->str_qc_main.str_qc_data[ch_idx].num_ch)) - return -1; + usac_data->str_qc_main.str_qc_data[ch_idx].num_ch); + if (err_code) { + return err_code; + } } } } @@ -1032,7 +1034,7 @@ IA_ERRORCODE ixheaace_usac_encode(FLOAT32 **ptr_input, ptr_usac_data->core_mode_next[i_ch] = CORE_MODE_TD; break; default: - return (-1); + return IA_EXHEAACE_INIT_FATAL_USAC_INVALID_CODEC_MODE; } if (ptr_usac_data->core_mode[i_ch] == CORE_MODE_TD) { for (i = 0; i < ptr_usac_config->ccfl; i++) { @@ -1340,5 +1342,5 @@ IA_ERRORCODE ixheaace_usac_encode(FLOAT32 **ptr_input, ptr_usac_data->available_bitreservoir_bits = ptr_usac_data->max_bitreservoir_bits; } - return 0; + return err; } diff --git a/encoder/iusace_fft.c b/encoder/iusace_fft.c index 0365f11..d17d208 100644 --- a/encoder/iusace_fft.c +++ b/encoder/iusace_fft.c @@ -45,6 +45,8 @@ #include "ixheaace_aac_constants.h" #include "ixheaac_basic_ops32.h" #include "ixheaace_common_utils.h" +#include "ixheaac_error_standards.h" +#include "ixheaace_error_codes.h" #define DIG_REV(i, m, j) \ do { \ @@ -909,7 +911,7 @@ IA_ERRORCODE iusace_fft_based_mdct(FLOAT64 *ptr_in, FLOAT64 *ptr_out, WORD32 npo sin_ptr = iusace_pre_post_twid_sin_2048; break; default: - return -1; + return IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_LENGTH; } /* pre-twiddle */ @@ -921,7 +923,7 @@ IA_ERRORCODE iusace_fft_based_mdct(FLOAT64 *ptr_in, FLOAT64 *ptr_out, WORD32 npo /* post-twiddle */ iusace_calc_post_twid_enc(ptr_out, ptr_scratch1, npoints << 1, cos_ptr, sin_ptr, tx_flag); - return 0; + return IA_NO_ERROR; } VOID iusace_complex_fft_2048(FLOAT32 *ptr_x, FLOAT32 *scratch_fft) { diff --git a/encoder/iusace_lpd_enc.c b/encoder/iusace_lpd_enc.c index 190771e..2ff2977 100644 --- a/encoder/iusace_lpd_enc.c +++ b/encoder/iusace_lpd_enc.c @@ -54,6 +54,7 @@ #include "iusace_lpd_rom.h" #include "iusace_lpd.h" #include "iusace_func_prototypes.h" +#include "ixheaac_error_standards.h" VOID iusace_init_td_data(ia_usac_td_encoder_struct *st, WORD32 len_frame) { WORD32 len_window; @@ -809,5 +810,5 @@ IA_ERRORCODE iusace_lpd_frm_enc(ia_usac_data_struct *usac_data, WORD32 *mod_out, td_encoder->prev_mode = (WORD16)mode[3]; memcpy(mod_out, mode, 4 * sizeof(WORD32)); - return 0; + return IA_NO_ERROR; } diff --git a/encoder/iusace_psy_utils.c b/encoder/iusace_psy_utils.c index bb03c15..8c0d040 100644 --- a/encoder/iusace_psy_utils.c +++ b/encoder/iusace_psy_utils.c @@ -45,6 +45,8 @@ #include "iusace_psy_utils.h" #include "iusace_fd_qc_util.h" #include "iusace_fd_qc_adjthr.h" +#include "ixheaac_error_standards.h" +#include "ixheaace_error_codes.h" extern ia_sfb_info_struct iusace_sfb_info_1024[12]; extern ia_sfb_info_struct iusace_sfb_info_768[12]; @@ -508,12 +510,12 @@ IA_ERRORCODE iusace_sfb_params_init(WORD32 sample_rate, WORD32 frame_len, WORD32 } else if (sample_rate >= 92017) { sampling_rate_mapped = 96000; } else { - return -1; + return IA_EXHEAACE_INIT_FATAL_USAC_INVALID_CORE_SAMPLE_RATE; } while (ptr_sr_info->sample_rate != sampling_rate_mapped) { if (ptr_sr_info->sample_rate == -1) { - return -1; + return IA_EXHEAACE_INIT_FATAL_USAC_INVALID_CORE_SAMPLE_RATE; } ptr_sr_info++; } @@ -546,5 +548,5 @@ IA_ERRORCODE iusace_sfb_params_init(WORD32 sample_rate, WORD32 frame_len, WORD32 break; } - return 0; + return IA_NO_ERROR; } diff --git a/encoder/iusace_tns_usac.c b/encoder/iusace_tns_usac.c index cb62a4f..22a72a6 100644 --- a/encoder/iusace_tns_usac.c +++ b/encoder/iusace_tns_usac.c @@ -30,6 +30,8 @@ #include "ixheaac_basic_ops32.h" #include "ixheaac_basic_ops40.h" #include "ixheaac_basic_ops.h" +#include "ixheaac_error_standards.h" +#include "ixheaace_error_codes.h" static const WORD32 iusace_tns_supported_sampling_rates[13] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 0}; @@ -92,6 +94,7 @@ static VOID iusace_calc_gauss_win(FLOAT64 *ptr_win, const WORD32 length, const W IA_ERRORCODE iusace_tns_init(WORD32 sampling_rate, WORD32 bit_rate, ia_tns_info *tns_info, WORD32 num_channels) { + IA_ERRORCODE err_code = IA_NO_ERROR; WORD32 fs_index = 0; WORD32 lpc_stop_freq = 16000; WORD32 lpc_start_freq_long = 2500, lpc_start_freq_short = 3750; @@ -127,7 +130,7 @@ IA_ERRORCODE iusace_tns_init(WORD32 sampling_rate, WORD32 bit_rate, ia_tns_info */ while (sampling_rate != iusace_tns_supported_sampling_rates[fs_index]) { if (!iusace_tns_supported_sampling_rates[fs_index]) { - return -1; + return IA_EXHEAACE_INIT_FATAL_USAC_INVALID_CORE_SAMPLE_RATE; } fs_index++; } @@ -159,7 +162,7 @@ IA_ERRORCODE iusace_tns_init(WORD32 sampling_rate, WORD32 bit_rate, ia_tns_info iusace_calc_gauss_win(tns_info->win_short, tns_info->tns_max_order_short + 1, sampling_rate, EIGHT_SHORT_SEQUENCE, tns_info->tns_time_res_short); - return 0; + return err_code; } VOID iusace_tns_filter(WORD32 length, FLOAT64 *spec, ia_tns_filter_data *filter, diff --git a/encoder/iusace_windowing.c b/encoder/iusace_windowing.c index 4bed683..a770686 100644 --- a/encoder/iusace_windowing.c +++ b/encoder/iusace_windowing.c @@ -19,11 +19,12 @@ */ #include <string.h> - +#include "ixheaac_error_standards.h" #include "ixheaac_type_def.h" #include "iusace_cnst.h" #include "iusace_block_switch_const.h" #include "iusace_rom.h" +#include "ixheaace_error_codes.h" IA_ERRORCODE iusace_calc_window(FLOAT64 **win, WORD32 win_sz, WORD32 win_sel) { switch (win_sel) { @@ -48,7 +49,7 @@ IA_ERRORCODE iusace_calc_window(FLOAT64 **win, WORD32 win_sz, WORD32 win_sel) { *win = (FLOAT64 *)iusace_sine_win_1024; break; default: - return -1; + return IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_LENGTH; break; } break; @@ -73,16 +74,16 @@ IA_ERRORCODE iusace_calc_window(FLOAT64 **win, WORD32 win_sz, WORD32 win_sel) { *win = (FLOAT64 *)iusace_kbd_win1024; break; default: - return -1; + return IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_LENGTH; break; } break; default: - return -1; + return IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_SHAPE; break; } - return 0; + return IA_NO_ERROR; } VOID iusace_windowing_long(FLOAT64 *ptr_overlap, FLOAT64 *ptr_win_long, FLOAT64 *ptr_win_buf, diff --git a/encoder/ixheaace_api.c b/encoder/ixheaace_api.c index cde050a..4bc7ddd 100644 --- a/encoder/ixheaace_api.c +++ b/encoder/ixheaace_api.c @@ -418,8 +418,8 @@ static VOID ia_enhaacplus_enc_allocate_bitrate_between_channels( } } -static WORD32 ixheaace_validate_channel_mask(WORD32 ch_mask, WORD32 num_ch) { - if (0 == ch_mask) return 0; +static IA_ERRORCODE ixheaace_validate_channel_mask(WORD32 ch_mask, WORD32 num_ch) { + IA_ERRORCODE err_code = IA_NO_ERROR; // If ch_mask not supported, return error WORD32 temp_mask; switch (num_ch) { @@ -446,11 +446,10 @@ static WORD32 ixheaace_validate_channel_mask(WORD32 ch_mask, WORD32 num_ch) { temp_mask = 0; break; } - if (ch_mask == temp_mask) { - return 0; - } else { - return -1; + if (ch_mask != temp_mask) { + err_code = IA_EXHEAACE_CONFIG_FATAL_CHANNELS_MASK; } + return err_code; } static VOID ixheaace_set_default_channel_mask(WORD32 *ch_mask, WORD32 num_ch) { @@ -1953,9 +1952,6 @@ static IA_ERRORCODE ia_usac_enc_init(ixheaace_api_struct *pstr_api_struct, WORD3 pstr_ia_asc_bit_buf = iusace_create_bit_buffer( &(pstr_api_struct->pstr_state->str_bit_buf), pstr_api_struct->pp_mem[IA_MEMTYPE_OUTPUT], pstr_api_struct->pstr_mem_info[IA_MEMTYPE_OUTPUT].ui_size, 1); -#ifdef ENABLE_SET_JUMP - pstr_ia_asc_bit_buf->iusace_jmp_buf = &api_init_jmp_buf; -#endif if (pstr_usac_config->sbr_enable) { pstr_api_struct->pstr_state->audio_specific_config.str_usac_config.str_usac_element_config ->stereo_config_index = (pstr_api_struct->pstr_state->mps_enable == 1) ? 2 : 0; @@ -2767,14 +2763,6 @@ static IA_ERRORCODE ia_enhaacplus_enc_execute(ixheaace_api_struct *pstr_api_stru static IA_ERRORCODE iusace_process(ixheaace_api_struct *pstr_api_struct) { IA_ERRORCODE error = IA_NO_ERROR; WORD32 idx; -#ifdef ENABLE_SET_JUMP - jmp_buf api_execute_jmp_buf; - error = setjmp(api_execute_jmp_buf); - if (error != IA_NO_ERROR) { - return IA_EXHEAACE_EXE_NONFATAL_USAC_INSUFFICIENT_WRITE_BUFFER_SIZE; - } -#endif // ENABLE_SET_JUMP - WORD32 write_off_set = 0; WORD32 core_coder_frame_length; WORD32 usac_independency_flg; @@ -3264,11 +3252,8 @@ static IA_ERRORCODE iusace_process(ixheaace_api_struct *pstr_api_struct) { iusace_create_bit_buffer(pstr_it_bit_buff, pstr_api_struct->pp_mem[IA_MEMTYPE_OUTPUT], pstr_api_struct->pstr_mem_info[IA_MEMTYPE_OUTPUT].ui_size, 1); if (pstr_it_bit_buff == NULL) { - return -1; + return IA_EXHEAACE_INIT_FATAL_USAC_BITBUFFER_INIT_FAILED; } -#ifdef ENABLE_SET_JUMP - pstr_it_bit_buff->iusace_jmp_buf = &api_execute_jmp_buf; -#endif error = ixheaace_usac_encode(pstr_api_struct->pstr_state->ptr_in_buf, pstr_config, &pstr_api_struct->pstr_state->str_usac_enc_data, diff --git a/encoder/ixheaace_asc_write.c b/encoder/ixheaace_asc_write.c index bc28857..436ef57 100644 --- a/encoder/ixheaace_asc_write.c +++ b/encoder/ixheaace_asc_write.c @@ -45,6 +45,7 @@ #include "ixheaace_aac_constants.h" #include "ixheaace_sbr_def.h" #include "ixheaace_common_rom.h" +#include "ixheaace_error_codes.h" static WORD32 ixheaace_spatial_specific_config(ia_bit_buf_struct *pstr_it_bit_buff, ia_aace_config_struct *pstr_eld_config) { @@ -232,8 +233,7 @@ static WORD32 iusace_encoder_config(ia_bit_buf_struct *pstr_it_bit_buff, bit_cnt += iusace_ext_element_config(pstr_it_bit_buff, pstr_usac_enc_conf); break; default: - return -1; - ; + return IA_EXHEAACE_INIT_FATAL_USAC_INVALID_ELEMENT_TYPE; break; } } diff --git a/encoder/ixheaace_bits_count.c b/encoder/ixheaace_bits_count.c index da938ef..6e5fa69 100644 --- a/encoder/ixheaace_bits_count.c +++ b/encoder/ixheaace_bits_count.c @@ -936,19 +936,13 @@ VOID ia_enhaacplus_enc_code_values(WORD16 *ptr_values, WORD32 width, WORD32 code } } -WORD32 ia_enhaacplus_enc_code_scale_factor_delta(WORD32 delta, - ixheaace_bit_buf_handle h_bitstream, - ixheaace_huffman_tables *pstr_huffman_tbl) { +VOID ia_enhaacplus_enc_code_scale_factor_delta(WORD32 delta, + ixheaace_bit_buf_handle h_bitstream, + ixheaace_huffman_tables *pstr_huffman_tbl) { WORD32 code_word, code_length; - if (abs32(delta) > CODE_BCK_SCF_LAV) { - return (1); - } - code_word = pstr_huffman_tbl->huff_ctabscf[delta + CODE_BCK_SCF_LAV]; code_length = pstr_huffman_tbl->huff_ltabscf[delta + CODE_BCK_SCF_LAV]; ixheaace_write_bits(h_bitstream, code_word, (UWORD8)code_length); - - return (0); } diff --git a/encoder/ixheaace_bits_count.h b/encoder/ixheaace_bits_count.h index ee20d36..70b5fe3 100644 --- a/encoder/ixheaace_bits_count.h +++ b/encoder/ixheaace_bits_count.h @@ -93,9 +93,9 @@ VOID ia_enhaacplus_enc_code_values(WORD16 *ptr_values, WORD32 width, WORD32 code ixheaace_bit_buf_handle pstr_bitstream, ixheaace_huffman_tables *pstr_huffman_tbl); -WORD32 ia_enhaacplus_enc_code_scale_factor_delta(WORD32 scalefactor, - ixheaace_bit_buf_handle h_bitstream, - ixheaace_huffman_tables *pstr_huffman_tbl); +VOID ia_enhaacplus_enc_code_scale_factor_delta(WORD32 scalefactor, + ixheaace_bit_buf_handle h_bitstream, + ixheaace_huffman_tables *pstr_huffman_tbl); VOID ia_enhaacplus_enc_count1_2_3_4_5_6_7_8_9_10_11(const WORD16 *values, const WORD32 width, WORD32 *bitcnt, diff --git a/encoder/ixheaace_error_codes.h b/encoder/ixheaace_error_codes.h index a0fe36f..b8ab469 100644 --- a/encoder/ixheaace_error_codes.h +++ b/encoder/ixheaace_error_codes.h @@ -116,6 +116,7 @@ typedef enum { IA_EXHEAACE_INIT_FATAL_NUM_CHANNELS_NOT_SUPPORTED, IA_EXHEAACE_INIT_FATAL_INVALID_NUM_CHANNELS_IN_ELE, IA_EXHEAACE_INIT_FATAL_SFB_TABLE_INIT_FAILED, + IA_EXHEAACE_INIT_FATAL_TNS_CONFIG_INIT_FAILED, // MPS IA_EXHEAACE_INIT_FATAL_MPS_INIT_FAILED = 0xFFFF9100, @@ -123,6 +124,10 @@ typedef enum { // USAC IA_EXHEAACE_INIT_FATAL_USAC_RESAMPLER_INIT_FAILED = 0xFFFF9200, IA_EXHEAACE_INIT_FATAL_USAC_BITRES_SIZE_TOO_SMALL, + IA_EXHEAACE_INIT_FATAL_USAC_INVALID_CORE_SAMPLE_RATE, + IA_EXHEAACE_INIT_FATAL_USAC_INVALID_ELEMENT_TYPE, + IA_EXHEAACE_INIT_FATAL_USAC_BITBUFFER_INIT_FAILED, + IA_EXHEAACE_INIT_FATAL_USAC_INVALID_CODEC_MODE, // DRC IA_EXHEAACE_INIT_FATAL_DRC_INVALID_CHANNEL_INDEX = 0xFFFF9300, @@ -135,6 +140,9 @@ typedef enum { IA_EXHEAACE_INIT_FATAL_SBR_INVALID_BUFFER_LENGTH, IA_EXEHAACE_INIT_FATAL_SBR_NOISE_BAND_NOT_SUPPORTED, + // PS + IA_EXHEAACE_INIT_FATAL_PS_INIT_FAILED = 0xFFFF9500, + /*****************************************************************************/ /* Class 3: Execution Errors */ /*****************************************************************************/ @@ -204,6 +212,9 @@ typedef enum { IA_EXHEAACE_EXE_FATAL_USAC_INVALID_NUM_CHANNEL, IA_EXHEAACE_EXE_FATAL_USAC_INVALID_BIT_RSVR_LVL, IA_EXHEAACE_EXE_FATAL_USAC_INVALID_MAPPING, + IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_TYPE, + IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_LENGTH, + IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_SHAPE, // DRC diff --git a/encoder/ixheaace_fd_mdct.c b/encoder/ixheaace_fd_mdct.c index 2ef6b74..bb53fa7 100644 --- a/encoder/ixheaace_fd_mdct.c +++ b/encoder/ixheaace_fd_mdct.c @@ -52,6 +52,7 @@ #include "ixheaace_asc_write.h" #include "iusace_main.h" #include "iusace_windowing.h" +#include "ixheaac_error_standards.h" static IA_ERRORCODE iusace_fd_mdct_short(ia_usac_data_struct *pstr_usac_data, ia_usac_encoder_config_struct *pstr_usac_config, @@ -196,7 +197,7 @@ static IA_ERRORCODE iusace_fd_mdct_long(ia_usac_data_struct *pstr_usac_data, return err_code_2; } - return 0; + return IA_NO_ERROR; } WORD32 iusace_fd_mdct(ia_usac_data_struct *pstr_usac_data, diff --git a/encoder/ixheaace_fd_quant.c b/encoder/ixheaace_fd_quant.c index 69f0a9f..4be4670 100644 --- a/encoder/ixheaace_fd_quant.c +++ b/encoder/ixheaace_fd_quant.c @@ -396,7 +396,7 @@ IA_ERRORCODE iusace_grouping(ia_sfb_params_struct *pstr_sfb_prms, WORD32 num_cha } pstr_sfb_prms->grouped_sfb_offset[ch][i] = k; } else { - return -1; + return IA_EXHEAACE_EXE_FATAL_USAC_INVALID_WINDOW_TYPE; } } @@ -438,7 +438,7 @@ IA_ERRORCODE iusace_grouping(ia_sfb_params_struct *pstr_sfb_prms, WORD32 num_cha } } } - return 0; + return IA_NO_ERROR; } IA_ERRORCODE iusace_quantize_spec(ia_sfb_params_struct *pstr_sfb_prms, diff --git a/encoder/ixheaace_hybrid_init.c b/encoder/ixheaace_hybrid_init.c index 22e7b13..e88ab23 100644 --- a/encoder/ixheaace_hybrid_init.c +++ b/encoder/ixheaace_hybrid_init.c @@ -21,7 +21,7 @@ #include <string.h> #include "ixheaac_type_def.h" - +#include "ixheaac_error_standards.h" #include "ixheaace_common_rom.h" #include "ixheaace_sbr_def.h" #include "ixheaace_resampler.h" @@ -61,5 +61,5 @@ ixheaace_create_hybrid_filter_bank(ixheaace_pstr_hybrid pstr_hybrid, FLOAT32 **p } *pptr_flt = ptr_flt; - return 0; + return IA_NO_ERROR; } diff --git a/encoder/ixheaace_mps_nlc_enc.c b/encoder/ixheaace_mps_nlc_enc.c index 4f5dae7..1a5254c 100644 --- a/encoder/ixheaace_mps_nlc_enc.c +++ b/encoder/ixheaace_mps_nlc_enc.c @@ -1581,13 +1581,13 @@ IA_ERRORCODE ixheaace_mps_212_ec_data_single_enc( return IA_NO_ERROR; } -WORD32 ixheaace_mps_515_ec_data_pair_enc(ixheaace_bit_buf_handle pstr_bit_buf, +VOID ixheaace_mps_515_ec_data_pair_enc(ixheaace_bit_buf_handle pstr_bit_buf, WORD32 pp_in_data[][MAXBANDS], WORD32 p_in_data[MAXBANDS], WORD32 data_type, WORD32 set_idx, WORD32 start_band, WORD32 data_bands, WORD32 pair_flag, WORD32 coarse_flag, WORD32 independency_flag) { - WORD32 dummy = 0, reset = 0; + WORD32 dummy = 0; WORD32 quant_levels = 0, quant_offset = 0, num_pcm_val = 0; WORD32 split_lsb_flag = 0; @@ -1666,7 +1666,7 @@ WORD32 ixheaace_mps_515_ec_data_pair_enc(ixheaace_bit_buf_handle pstr_bit_buf, break; default: - return 0; + return; } memcpy(a_data_hist, p_in_data + start_band, sizeof(WORD32) * data_bands); @@ -1910,5 +1910,5 @@ WORD32 ixheaace_mps_515_ec_data_pair_enc(ixheaace_bit_buf_handle pstr_bit_buf, } } - return reset; + return; } diff --git a/encoder/ixheaace_mps_sac_nlc_enc.h b/encoder/ixheaace_mps_sac_nlc_enc.h index 257e8bd..ff7c6aa 100644 --- a/encoder/ixheaace_mps_sac_nlc_enc.h +++ b/encoder/ixheaace_mps_sac_nlc_enc.h @@ -19,7 +19,7 @@ */ #pragma once -WORD32 ixheaace_mps_515_ec_data_pair_enc(ixheaace_bit_buf_handle strm, +VOID ixheaace_mps_515_ec_data_pair_enc(ixheaace_bit_buf_handle strm, WORD32 aa_in_data[][MAXBANDS], WORD32 a_history[MAXBANDS], WORD32 data_type, WORD32 set_idx, WORD32 start_band, WORD32 data_bands, diff --git a/encoder/ixheaace_nf.c b/encoder/ixheaace_nf.c index a49f02f..0a9de9b 100644 --- a/encoder/ixheaace_nf.c +++ b/encoder/ixheaace_nf.c @@ -62,9 +62,17 @@ static VOID iusace_noise_filling_limiter(FLOAT64 *energy, FLOAT64 *ptr_spec, } /* remove the contribution of the highest_tone components */ for (n = 0; n < n0_by_4; n++) tot_tone_energy += ptr_highest_tone[n]; - *energy -= tot_tone_energy; - if (fabs(*energy) < DBL_EPSILON) + + FLOAT64 diff = *energy - tot_tone_energy; + //If the difference is within 1% of total energy, no need to send any energy + if (diff < 0.01*(*energy)) + { *energy = 0.0; + } + else + { + *energy = diff; + } /* add the average component energy */ *energy += n0_by_4 * (*energy) / (cntr - n0_by_4); @@ -124,8 +132,8 @@ VOID iusace_noise_filling(WORD32 *noise_level, WORD32 *noise_offset, FLOAT64 *pt /* Remove highest (tonal) contributions */ iusace_noise_filling_limiter(&energy, &ptr_quant_spec[offset], - &(pstr_quant_info->quant_degroup[offset]), n0 / 4, ptr_sfb_offset, sfb, - n0, ptr_scratch_buf); + &pstr_quant_info->quant_degroup[offset], n0 / 4, + ptr_sfb_offset, sfb, n0, ptr_scratch_buf); if (band_quantized_to_zero == 0) { e_sfb_on += energy; diff --git a/encoder/ixheaace_ps_enc_init.c b/encoder/ixheaace_ps_enc_init.c index b4ba882..c055184 100644 --- a/encoder/ixheaace_ps_enc_init.c +++ b/encoder/ixheaace_ps_enc_init.c @@ -19,7 +19,7 @@ */ #include <string.h> - +#include "ixheaac_error_standards.h" #include "ixheaac_type_def.h" #include "ixheaace_sbr_def.h" #include "ixheaace_resampler.h" @@ -30,7 +30,7 @@ #include "ixheaace_sbr_ps_enc.h" #include "ixheaac_constants.h" #include "ixheaace_aac_constants.h" - +#include "ixheaace_error_codes.h" #include "ixheaace_bitbuffer.h" WORD32 ixheaace_get_ps_mode(WORD32 bitrate) { @@ -43,24 +43,23 @@ WORD32 ixheaace_get_ps_mode(WORD32 bitrate) { return ps_mode; } -WORD32 +IA_ERRORCODE ixheaace_create_ps_enc(ixheaace_pstr_ps_enc pstr_ps_enc, WORD32 ps_mode, FLOAT32 *ptr_common_buffer, FLOAT32 *ptr_common_buffer2, FLOAT32 *ptr_ps_buf3) { WORD32 i; - WORD32 err; + IA_ERRORCODE err = IA_NO_ERROR; FLOAT32 *ptr1, *ptr2, *ptr3, *ptr4; + if (pstr_ps_enc == NULL) { + return IA_EXHEAACE_INIT_FATAL_PS_INIT_FAILED; + } ptr1 = &ptr_common_buffer2[IXHEAACE_QMF_TIME_SLOTS * IXHEAACE_QMF_CHANNELS]; ptr2 = pstr_ps_enc->ps_buf2; ptr3 = ptr_ps_buf3; ptr4 = &ptr_common_buffer[5 * NO_OF_ESTIMATES * MAXIMUM_FREQ_COEFFS]; - if (pstr_ps_enc == NULL) { - return 1; - } - pstr_ps_enc->ps_mode = ps_mode; pstr_ps_enc->b_prev_zero_iid = 0; pstr_ps_enc->b_prev_zero_icc = 0; @@ -93,14 +92,14 @@ ixheaace_create_ps_enc(ixheaace_pstr_ps_enc pstr_ps_enc, WORD32 ps_mode, err = ixheaace_create_hybrid_filter_bank(pstr_ps_enc->ptr_hybrid_left, &ptr4); - if (err != 0) { - return 1; + if (err) { + return err; } err = ixheaace_create_hybrid_filter_bank(pstr_ps_enc->ptr_hybrid_right, &ptr4); - if (err != 0) { - return 1; + if (err) { + return err; } for (i = 0; i < NUMBER_OF_SUBSAMPLES; i++) { @@ -189,7 +188,7 @@ ixheaace_create_ps_enc(ixheaace_pstr_ps_enc pstr_ps_enc, WORD32 ps_mode, if ((pstr_ps_enc->hist_qmf_left_real == NULL) || (pstr_ps_enc->hist_qmf_left_imag == NULL) || (pstr_ps_enc->hist_qmf_right_real == NULL) || (pstr_ps_enc->hist_qmf_right_imag == NULL)) { - return 1; + return IA_EXHEAACE_INIT_FATAL_PS_INIT_FAILED; } for (i = 0; i < pstr_ps_enc->iid_icc_bins; i++) { @@ -207,5 +206,5 @@ ixheaace_create_ps_enc(ixheaace_pstr_ps_enc pstr_ps_enc, WORD32 ps_mode, pstr_ps_enc->ps_bit_buf.ptr_write_next = pstr_ps_enc->ps_bit_buf.ptr_bit_buf_base + pstr_ps_enc->bit_buf_write_offset; - return 0; + return err; } diff --git a/encoder/ixheaace_qc_util.c b/encoder/ixheaace_qc_util.c index 7f21837..0cd022b 100644 --- a/encoder/ixheaace_qc_util.c +++ b/encoder/ixheaace_qc_util.c @@ -111,9 +111,9 @@ static WORD32 ia_enhaacplus_enc_frame_padding(WORD32 bit_rate, WORD32 sample_rat return padding_on; } -WORD32 ia_enhaacplus_enc_qc_out_new(ixheaace_qc_out *pstr_qc_out, WORD32 num_channels, - WORD32 *ptr_shared_buffer1, WORD32 *ptr_shared_buffer3, - WORD32 long_frame_len) +IA_ERRORCODE ia_enhaacplus_enc_qc_out_new(ixheaace_qc_out *pstr_qc_out, WORD32 num_channels, + WORD32 *ptr_shared_buffer1, WORD32 *ptr_shared_buffer3, + WORD32 long_frame_len) { WORD32 i; @@ -140,18 +140,20 @@ WORD32 ia_enhaacplus_enc_qc_out_new(ixheaace_qc_out *pstr_qc_out, WORD32 num_cha sizeof(*pstr_qc_out->qc_channel[i]->scalefactor) * MAXIMUM_GROUPED_SCALE_FACTOR_BAND); } - return (pstr_qc_out == NULL); + if (pstr_qc_out == NULL) { + return IA_EXHEAACE_INIT_FATAL_AAC_INIT_FAILED; + } + return IA_NO_ERROR; } -WORD32 ia_enhaacplus_enc_qc_new(ixheaace_qc_state *pstr_qc_state, WORD32 *ptr_shared_buffer_2, - WORD32 long_frame_len - +IA_ERRORCODE ia_enhaacplus_enc_qc_new(ixheaace_qc_state *pstr_qc_state, + WORD32 *ptr_shared_buffer_2, WORD32 long_frame_len ) { memset(pstr_qc_state, 0, sizeof(ixheaace_qc_state)); pstr_qc_state->qc_scr.shared_buffer_2 = (ptr_shared_buffer_2 + long_frame_len * IXHEAACE_MAX_CH_IN_BS_ELE + 16); - return (0); + return IA_NO_ERROR; } IA_ERRORCODE ia_enhaacplus_enc_qc_init(ixheaace_qc_state *pstr_qc_state, WORD32 aot, diff --git a/encoder/ixheaace_qc_util.h b/encoder/ixheaace_qc_util.h index 3886472..6e971cd 100644 --- a/encoder/ixheaace_qc_util.h +++ b/encoder/ixheaace_qc_util.h @@ -20,12 +20,12 @@ #pragma once -WORD32 ia_enhaacplus_enc_qc_out_new(ixheaace_qc_out *pstr_qc_out, WORD32 num_channels, - WORD32 *ptr_shared_buffer1, WORD32 *ptr_shared_buffer3, - WORD32 frame_len_long); +IA_ERRORCODE ia_enhaacplus_enc_qc_out_new(ixheaace_qc_out *pstr_qc_out, WORD32 num_channels, + WORD32 *ptr_shared_buffer1, WORD32 *ptr_shared_buffer3, + WORD32 frame_len_long); -WORD32 ia_enhaacplus_enc_qc_new(ixheaace_qc_state *pstr_qc_state, WORD32 *ptr_shared_buffer_2, - WORD32 frame_len_long); +IA_ERRORCODE ia_enhaacplus_enc_qc_new(ixheaace_qc_state *pstr_qc_state, + WORD32 *ptr_shared_buffer_2, WORD32 frame_len_long); IA_ERRORCODE ia_enhaacplus_enc_qc_init(ixheaace_qc_state *pstr_qc_state, WORD32 aot, ixheaace_qc_init *pstr_init, FLAG flag_framelength_small); diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index 5fe2ea7..bf7bafa 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -292,21 +292,7 @@ ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs) result = (result * fs / qmf_bands + 1) >> 1; - return (result); -} - -WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs) { - WORD32 result; - - if ((stop_freq < 0) || (stop_freq > 13)) { - return -1; - } - - result = ixheaace_get_stop_freq(fs, stop_freq); - - result = (result * fs / qmf_bands + 1) >> 1; - - return (result); + return result; } static WORD32 ixheaace_number_of_bands(WORD32 b_p_o, WORD32 start, WORD32 stop, diff --git a/encoder/ixheaace_sbr_freq_scaling.h b/encoder/ixheaace_sbr_freq_scaling.h index 1a04a35..fe107e1 100644 --- a/encoder/ixheaace_sbr_freq_scaling.h +++ b/encoder/ixheaace_sbr_freq_scaling.h @@ -43,5 +43,3 @@ ixheaace_find_start_and_stop_band(const WORD32 sampling_freq, const WORD32 num_c ixheaace_sbr_codec_type sbr_codec); WORD32 ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs); - -WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs); diff --git a/encoder/ixheaace_sbr_ps_enc.h b/encoder/ixheaace_sbr_ps_enc.h index 0c43c39..58c00a5 100644 --- a/encoder/ixheaace_sbr_ps_enc.h +++ b/encoder/ixheaace_sbr_ps_enc.h @@ -90,7 +90,7 @@ typedef struct ixheaace_ps_enc *ixheaace_pstr_ps_enc; WORD32 ixheaace_get_ps_mode(WORD32 bit_rate); -WORD32 +IA_ERRORCODE ixheaace_create_ps_enc(ixheaace_pstr_ps_enc pstr_ps_enc, WORD32 ps_mode, FLOAT32 *ptr_common_buffer, FLOAT32 *ptr_common_buffer2, FLOAT32 *ptr_ps_buf3); diff --git a/encoder/ixheaace_stereo_preproc.c b/encoder/ixheaace_stereo_preproc.c index 644f5b1..a14fe7e 100644 --- a/encoder/ixheaace_stereo_preproc.c +++ b/encoder/ixheaace_stereo_preproc.c @@ -43,11 +43,11 @@ #include "ixheaace_adjust_threshold_data.h" #include "ixheaace_dynamic_bits.h" #include "ixheaace_qc_data.h" - +#include "ixheaac_error_standards.h" #include "ixheaace_stereo_preproc.h" #include "ixheaace_common_utils.h" -WORD32 iaace_init_stereo_pre_processing(ixheaace_stereo_pre_pro_pstr pstr_stereo_pre_pro, +IA_ERRORCODE iaace_init_stereo_pre_processing(ixheaace_stereo_pre_pro_pstr pstr_stereo_pre_pro, WORD32 no_channels, WORD32 bit_rate, WORD32 sample_rate, FLOAT32 used_scf_ratio) { FLOAT32 bpf = bit_rate * 1024.0f / sample_rate; @@ -96,7 +96,7 @@ WORD32 iaace_init_stereo_pre_processing(ixheaace_stereo_pre_pro_pstr pstr_stereo tmp * (pstr_stereo_pre_pro)->stereo_attenuation_max; } - return 0; + return IA_NO_ERROR; } VOID iaace_apply_stereo_preproc(ixheaace_stereo_pre_pro_pstr pstr_stereo_pre_pro, diff --git a/encoder/ixheaace_stereo_preproc.h b/encoder/ixheaace_stereo_preproc.h index 60fd52f..9ecb046 100644 --- a/encoder/ixheaace_stereo_preproc.h +++ b/encoder/ixheaace_stereo_preproc.h @@ -50,7 +50,7 @@ typedef struct { typedef ixheaace_stereo_pre_pro_struct *ixheaace_stereo_pre_pro_pstr; -WORD32 iaace_init_stereo_pre_processing(ixheaace_stereo_pre_pro_pstr pstr_stereo_pre_pro, +IA_ERRORCODE iaace_init_stereo_pre_processing(ixheaace_stereo_pre_pro_pstr pstr_stereo_pre_pro, WORD32 no_channels, WORD32 bit_rate, WORD32 sample_rate, FLOAT32 used_scf_ratio); diff --git a/encoder/ixheaace_tns.c b/encoder/ixheaace_tns.c index 2babda6..288c460 100644 --- a/encoder/ixheaace_tns.c +++ b/encoder/ixheaace_tns.c @@ -291,7 +291,7 @@ static VOID ia_enhaacplus_enc_index_to_parcor( } } -WORD32 ia_enhaacplus_enc_tns_encode(ixheaace_temporal_noise_shaping_params *pstr_tns_info, +VOID ia_enhaacplus_enc_tns_encode(ixheaace_temporal_noise_shaping_params *pstr_tns_info, ixheaace_temporal_noise_shaping_data *pstr_tns_data, WORD32 num_sfb, ixheaace_temporal_noise_shaping_config tns_config, @@ -304,7 +304,7 @@ WORD32 ia_enhaacplus_enc_tns_encode(ixheaace_temporal_noise_shaping_params *pstr if (block_type != SHORT_WINDOW) { if (pstr_tns_data->data_raw.tns_data_long.sub_block_info.tns_active == 0) { pstr_tns_info->tns_active[sub_blk_num] = 0; - return 0; + return; } else { ia_enhaacplus_enc_parcor_to_index( pstr_tns_data->data_raw.tns_data_long.sub_block_info.parcor, &pstr_tns_info->coef[0], @@ -347,7 +347,7 @@ WORD32 ia_enhaacplus_enc_tns_encode(ixheaace_temporal_noise_shaping_params *pstr if (pstr_tns_data->data_raw.tns_data_short.sub_block_info[sub_blk_num].tns_active == 0) { pstr_tns_info->tns_active[sub_blk_num] = 0; - return 0; + return; } else { ia_enhaacplus_enc_parcor_to_index( pstr_tns_data->data_raw.tns_data_short.sub_block_info[sub_blk_num].parcor, @@ -384,7 +384,7 @@ WORD32 ia_enhaacplus_enc_tns_encode(ixheaace_temporal_noise_shaping_params *pstr } } - return 0; + return; } VOID ia_enhaacplus_enc_apply_tns_mult_table_to_ratios(WORD32 start_cb, WORD32 stop_cb, diff --git a/encoder/ixheaace_tns_func.h b/encoder/ixheaace_tns_func.h index cbd73d8..0105ef2 100644 --- a/encoder/ixheaace_tns_func.h +++ b/encoder/ixheaace_tns_func.h @@ -45,7 +45,7 @@ VOID ia_enhaacplus_enc_tns_sync(ixheaace_temporal_noise_shaping_data *pstr_tns_d const ixheaace_temporal_noise_shaping_config tns_config, const WORD32 sub_blk_num, const WORD32 block_type); -WORD32 ia_enhaacplus_enc_tns_encode(ixheaace_temporal_noise_shaping_params *pstr_tns_info, +VOID ia_enhaacplus_enc_tns_encode(ixheaace_temporal_noise_shaping_params *pstr_tns_info, ixheaace_temporal_noise_shaping_data *pstr_tns_data, WORD32 num_sfb, ixheaace_temporal_noise_shaping_config tns_config, diff --git a/encoder/ixheaace_tns_params.c b/encoder/ixheaace_tns_params.c index 3a165fa..c63bb27 100644 --- a/encoder/ixheaace_tns_params.c +++ b/encoder/ixheaace_tns_params.c @@ -43,7 +43,9 @@ ia_enhaacplus_enc_get_tns_param( const ixheaace_temporal_noise_shaping_info_tab *pstr_tns_info_tab, WORD32 size) { UWORD32 i; - if (pstr_tns_config_tab == NULL) return 1; + if (pstr_tns_config_tab == NULL) { + return IA_EXHEAACE_INIT_FATAL_TNS_CONFIG_INIT_FAILED; + } pstr_tns_config_tab->thresh_on = -1; diff --git a/encoder/ixheaace_write_adts_adif.c b/encoder/ixheaace_write_adts_adif.c index e7f080d..2cda5bb 100644 --- a/encoder/ixheaace_write_adts_adif.c +++ b/encoder/ixheaace_write_adts_adif.c @@ -35,7 +35,7 @@ #include "ixheaac_basic_ops.h" #include "ixheaace_common_utils.h" -static WORD32 ia_enhaacplus_enc_putbit(ixheaace_bitstream_params *pstr_bitstream, UWORD32 data, +static VOID ia_enhaacplus_enc_putbit(ixheaace_bitstream_params *pstr_bitstream, UWORD32 data, WORD32 num_bit) { WORD32 num, max_num, curr_num; WORD32 num_used, idx; @@ -43,7 +43,7 @@ static WORD32 ia_enhaacplus_enc_putbit(ixheaace_bitstream_params *pstr_bitstream WORD32 current_bitstream_bit; UWORD8 *bitstream_data; - if (num_bit == 0) return 0; + if (num_bit == 0) return; current_bitstream_bit = pstr_bitstream->current_bit; bitstream_data = pstr_bitstream->data; @@ -99,8 +99,6 @@ static WORD32 ia_enhaacplus_enc_putbit(ixheaace_bitstream_params *pstr_bitstream pstr_bitstream->current_bit = current_bitstream_bit; pstr_bitstream->num_bit = current_bitstream_bit; - - return 0; } static WORD16 ia_enhaacplus_enc_get_sample_rate_index(WORD32 sample_rate) { diff --git a/encoder/ixheaace_write_bitstream.c b/encoder/ixheaace_write_bitstream.c index 5b33976..9851f26 100644 --- a/encoder/ixheaace_write_bitstream.c +++ b/encoder/ixheaace_write_bitstream.c @@ -185,7 +185,7 @@ static WORD32 ia_enhaacplus_enc_encode_section_data( return (ia_enhaacplus_enc_get_bits_available(pstr_bit_stream_handle) - dbg_val); } -static WORD32 ia_enhaacplus_enc_code_scale_factor_delta_lav(WORD32 delta, +static VOID ia_enhaacplus_enc_code_scale_factor_delta_lav(WORD32 delta, ixheaace_bit_buf_handle ptr_bitstream, const UWORD16 *ptr_pltabscf, const UWORD32 *ptr_pctabscf) { @@ -195,8 +195,6 @@ static WORD32 ia_enhaacplus_enc_code_scale_factor_delta_lav(WORD32 delta, code_length = ptr_pltabscf[delta]; ixheaace_write_bits(ptr_bitstream, code_word, (UWORD8)code_length); - - return 0; } static WORD32 ia_enhaacplus_enc_encode_scalefactor_data( UWORD16 *ptr_max_val_in_sfb, ixheaace_section_data *pstr_section_data, WORD16 *ptr_scalefac, @@ -220,10 +218,8 @@ static WORD32 ia_enhaacplus_enc_encode_scalefactor_data( last_val_scf = ptr_scalefac[j]; } - if (ia_enhaacplus_enc_code_scale_factor_delta_lav(delta_scf, pstr_bit_stream_handle, - ptr_pltabscf, ptr_pctabscf)) { - return 1; - } + ia_enhaacplus_enc_code_scale_factor_delta_lav(delta_scf, pstr_bit_stream_handle, + ptr_pltabscf, ptr_pctabscf); } } } @@ -767,7 +763,7 @@ IA_ERRORCODE ia_enhaacplus_enc_write_bitstream( } break; default: - return 1; + return IA_EXHEAACE_INIT_FATAL_INVALID_ELEMENT_TYPE; } /* switch */ diff --git a/fuzzer/xaac_enc_fuzzer.cpp b/fuzzer/xaac_enc_fuzzer.cpp index b7c9d47..252d898 100644 --- a/fuzzer/xaac_enc_fuzzer.cpp +++ b/fuzzer/xaac_enc_fuzzer.cpp @@ -406,7 +406,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { while (fuzzed_data.remaining_bytes()) { if (fuzzed_data.ConsumeBool()) { std::vector<WORD8> inputVec = fuzzed_data.ConsumeBytes<WORD8>(input_size); - if(inputVec.size()) { + if (inputVec.size()) { memcpy(pb_inp_buf, inputVec.data(), inputVec.size()); } } else { diff --git a/test/encoder/ixheaace_error.c b/test/encoder/ixheaace_error.c index eccb2f7..81cdd96 100644 --- a/test/encoder/ixheaace_error.c +++ b/test/encoder/ixheaace_error.c @@ -98,13 +98,16 @@ pWORD8 ppb_ia_enhaacplus_enc_init_fatal[IA_MAX_ERROR_SUB_CODE] = { (pWORD8) "Invalid element type", (pWORD8) "Number of channels not supported", (pWORD8) "Invalid number of channels in element", - (pWORD8) "Scale factor band initalization failed"}; + (pWORD8) "Scale factor band initalization failed", + (pWORD8) "TNS configuration initalization failed" }; pWORD8 ppb_ia_enhaacplus_enc_mps_init_fatal[IA_MAX_ERROR_SUB_CODE] = { (pWORD8) "MPS Initialization failed"}; pWORD8 ppb_ia_enhaacplus_enc_usac_init_fatal[IA_MAX_ERROR_SUB_CODE] = { - (pWORD8) "Resampler initialization failed", (pWORD8) "Insufficient bit-reservoir size"}; + (pWORD8) "Resampler initialization failed", (pWORD8) "Insufficient bit-reservoir size", + (pWORD8) "Invalid core sample rate", (pWORD8) "Invalid element type", + (pWORD8) "Bitbuffer initialization failed", (pWORD8) "Invalid codec mode"}; pWORD8 ppb_ia_enhaacplus_enc_drc_init_fatal[IA_MAX_ERROR_SUB_CODE] = { (pWORD8) "Invalid channel index"}; @@ -114,6 +117,9 @@ pWORD8 ppb_ia_enhaacplus_enc_sbr_init_fatal[IA_MAX_ERROR_SUB_CODE] = { (pWORD8) "Invalid frequency coefficients", (pWORD8) "Invalid number of bands", (pWORD8) "Invalid buffer length", (pWORD8) "SBR noise band not supported"}; +pWORD8 ppb_ia_enhaacplus_enc_ps_init_fatal[IA_MAX_ERROR_SUB_CODE] = { + (pWORD8) "PS Initialization failed" }; + /*****************************************************************************/ /* Class 2: Execution Errors *****************************************************************************/ @@ -180,6 +186,9 @@ pWORD8 ppb_ia_enhaacplus_enc_usac_exe_fatal[IA_MAX_ERROR_SUB_CODE] = { (pWORD8) "Invalid number of channels", (pWORD8) "Invalid bit reservoir level", (pWORD8) "Invalid mapping", + (pWORD8) "Invalid window type", + (pWORD8) "Invalid window length", + (pWORD8) "Invalid window shape", }; /*****************************************************************************/ @@ -231,7 +240,7 @@ VOID ia_enhaacplus_enc_error_handler_init() { ppb_ia_enhaacplus_enc_config_non_fatal; ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[0][1][1] = ppb_ia_enhaacplus_enc_mps_config_non_fatal; - ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[0][1][2] = + ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[0][1][3] = ppb_ia_enhaacplus_enc_drc_config_non_fatal; ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[1][1][0] = ppb_ia_enhaacplus_enc_config_fatal; @@ -251,6 +260,8 @@ VOID ia_enhaacplus_enc_error_handler_init() { ppb_ia_enhaacplus_enc_drc_init_fatal; ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[1][2][4] = ppb_ia_enhaacplus_enc_sbr_init_fatal; + ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[1][2][5] = + ppb_ia_enhaacplus_enc_ps_init_fatal; ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[0][3][1] = ppb_ia_enhaacplus_enc_mps_exe_non_fatal; ia_enhaacplus_enc_error_info.ppppb_error_msg_pointers[0][3][4] = @@ -308,6 +319,9 @@ IA_ERRORCODE ia_error_handler(ia_error_info_struct *p_mod_err_info, WORD8 *pb_co case 4: printf("SBR/eSBR "); break; + case 5: + printf("Parametric Stereo "); + break; default: break; } diff --git a/test/encoder/ixheaace_wav_reader.c b/test/encoder/ixheaace_wav_reader.c deleted file mode 100644 index bae8b8b..0000000 --- a/test/encoder/ixheaace_wav_reader.c +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * * - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore - */ - -#include "ixheaac_type_def.h" -#include "ixheaace_wave_read.h" - -WORD32 ia_enhaacplus_enc_get_wav_info(UWORD8 *inptr, wav_file_info *wav_info) { - UWORD8 *wav_hdr = inptr; - WORD8 data_start[4]; - WORD16 num_ch; - UWORD16 f_samp; - - if (wav_hdr[0] != 'R' && wav_hdr[1] != 'I' && wav_hdr[2] != 'F' && wav_hdr[3] != 'F') { - return 0; - } - - if (wav_hdr[20] != 01 && wav_hdr[21] != 00) { - return 0; - } - num_ch = (WORD16)((UWORD8)wav_hdr[23] * 256 + (UWORD8)wav_hdr[22]); - f_samp = ((UWORD8)wav_hdr[27] * 256 * 256 * 256); - f_samp += ((UWORD8)wav_hdr[26] * 256 * 256); - f_samp += ((UWORD8)wav_hdr[25] * 256); - f_samp += ((UWORD8)wav_hdr[24]); - - wav_info->num_channels = num_ch; - wav_info->sample_rate = f_samp; - - data_start[0] = wav_hdr[36]; - data_start[1] = wav_hdr[37]; - data_start[2] = wav_hdr[38]; - data_start[3] = wav_hdr[39]; - - if (!(data_start[0] == 'd' && data_start[1] == 'a' && data_start[2] == 't' && - data_start[3] == 'a')) { - return 0; - } - - return 1; -} diff --git a/test/encoder/ixheaace_wave_read.h b/test/encoder/ixheaace_wave_read.h deleted file mode 100644 index 1f35916..0000000 --- a/test/encoder/ixheaace_wave_read.h +++ /dev/null @@ -1,30 +0,0 @@ -/****************************************************************************** - * * - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ***************************************************************************** - * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore - */ - -#pragma once -typedef struct { - WORD32 valid; - WORD32 bits_per_sample; - WORD32 sample_rate; - WORD32 num_channels; - long num_samples; - WORD32 is_little_endian; - WORD32 use_wave_ext; -} wav_file_info; diff --git a/test/encoder/xaacenc.cmake b/test/encoder/xaacenc.cmake index 713d357..a7930d2 100644 --- a/test/encoder/xaacenc.cmake +++ b/test/encoder/xaacenc.cmake @@ -1,8 +1,7 @@ list(APPEND XAACENC_SRCS "${XAAC_ROOT}/test/encoder/impd_drc_user_config.c" "${XAAC_ROOT}/test/encoder/ixheaace_error.c" - "${XAAC_ROOT}/test/encoder/ixheaace_testbench.c" - "${XAAC_ROOT}/test/encoder/ixheaace_wav_reader.c") + "${XAAC_ROOT}/test/encoder/ixheaace_testbench.c") set(LIBXAACENC_INCLUDES ${XAAC_ROOT}/encoder ${XAAC_ROOT}/test/encoder |