From 63b52afd851374700472813ee0de537c2c1c94a9 Mon Sep 17 00:00:00 2001 From: Shashank Pathmudi Date: Tue, 16 Jan 2024 18:16:02 +0530 Subject: [PATCH] Decoder Enhancements [x] Aligned buffer access for persistent memory. --- common/ixheaac_constants.h | 3 + decoder/drc_src/impd_drc_api.c | 121 ++++++--- decoder/drc_src/impd_drc_common.h | 15 +- decoder/drc_src/impd_drc_gain_decoder.c | 85 ++++--- decoder/drc_src/impd_drc_init.c | 67 +++-- decoder/drc_src/impd_drc_parametric_dec.c | 7 +- decoder/ixheaacd_api.c | 184 ++++++++------ decoder/ixheaacd_cnst.h | 2 + decoder/ixheaacd_common_initfuncs.c | 5 +- decoder/ixheaacd_create.c | 2 +- decoder/ixheaacd_initfuncs.c | 49 ++-- decoder/ixheaacd_mps_initfuncs.c | 279 +++++++++++++-------- decoder/ixheaacd_sbrdec_initfuncs.c | 283 +++++++++++++++------- 13 files changed, 706 insertions(+), 396 deletions(-) diff --git a/common/ixheaac_constants.h b/common/ixheaac_constants.h index f9f8c31..361b8ba 100644 --- a/common/ixheaac_constants.h +++ b/common/ixheaac_constants.h @@ -83,4 +83,7 @@ #define C76 (0.5339693427f) //(sin(u) - 2 * sin(2 * u) - sin(3 * u)) / 3; #define C77 (-0.8748422265f) //(sin(u) + sin(2 * u) + 2 * sin(3 * u)) / 3; +#define BYTE_ALIGN_8 (8) +#define IXHEAAC_GET_SIZE_ALIGNED(size, alignment) ((size + (alignment - 1)) & ~(alignment - 1)) + #endif /* IXHEAAC_CONSTANTS_H */ diff --git a/decoder/drc_src/impd_drc_api.c b/decoder/drc_src/impd_drc_api.c index d31c93f..94ddccc 100644 --- a/decoder/drc_src/impd_drc_api.c +++ b/decoder/drc_src/impd_drc_api.c @@ -26,6 +26,7 @@ #include "impd_drc_bitbuffer.h" #include "impd_drc_extr_delta_coded_info.h" +#include "ixheaac_constants.h" #include "impd_drc_common.h" #include "impd_drc_struct.h" #include "impd_drc_interface.h" @@ -61,41 +62,7 @@ IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc); IA_ERRORCODE impd_drc_set_struct_pointer(ia_drc_api_struct *p_obj_drc); IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc); -#define SUBBAND_BUF_SIZE \ - NUM_ELE_IN_CPLX_NUM *MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \ - (MAX_SUBBAND_DELAY + MAX_DRC_FRAME_SIZE) * MAX_CHANNEL_COUNT * \ - sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM - #define NUM_DRC_TABLES 4 -#define SCRATCH_MEM_SIZE \ - (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \ - NUM_ELE_IN_CPLX_NUM) - -#define PERSIST_MEM_SIZE \ - (sizeof(ia_drc_state_struct) + sizeof(ia_drc_bits_dec_struct) + \ - sizeof(ia_drc_gain_dec_struct) * 2 + \ - sizeof(ia_drc_loudness_info_set_struct) + sizeof(ia_drc_gain_struct) + \ - sizeof(ia_drc_interface_struct) + sizeof(ia_drc_config) + \ - sizeof(ia_drc_sel_pro_struct) + sizeof(ia_drc_sel_proc_params_struct) + \ - sizeof(ia_drc_sel_proc_output_struct) + \ - sizeof(ia_drc_peak_limiter_struct) + sizeof(ia_drc_peak_limiter_struct) + \ - sizeof(ia_drc_qmf_filt_struct) + ANALY_BUF_SIZE + SYNTH_BUF_SIZE + \ - PEAK_LIM_BUF_SIZE + MAX_DRC_BS_BUF_SIZE + \ - MAX_DRC_CONFG_BUF_SIZE + /*DRC Config Bitstream*/ \ - MAX_LOUD_INFO_BUF_SIZE + /*DRC loudness info Bitstream*/ \ - MAX_INTERFACE_BUF_SIZE + /*DRC interface Bitstream*/ \ - NUM_GAIN_DEC_INSTANCES * \ - (SEL_DRC_COUNT * sizeof(ia_interp_buf_struct) * MAX_GAIN_ELE_COUNT + \ - sizeof(ia_eq_set_struct) + /*non_interleaved_audio*/ \ - MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \ - MAX_DRC_FRAME_SIZE * sizeof(FLOAT32) * \ - MAX_CHANNEL_COUNT + /*audio_in_out_buf ptr*/ \ - MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + /*audio_io_buffer_delayed*/ \ - MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \ - MAX_DRC_FRAME_SIZE * sizeof(FLOAT32) * \ - MAX_CHANNEL_COUNT + /*subband band buffer ptr*/ \ - NUM_ELE_IN_CPLX_NUM * MAX_CHANNEL_COUNT * sizeof(FLOAT32 *) + \ - SUBBAND_BUF_SIZE + (PARAM_DRC_MAX_BUF_SZ * MAX_CHANNEL_COUNT))) IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, pVOID pv_value) { @@ -152,7 +119,7 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, case IA_CMD_TYPE_INIT_SET_BUFF_PTR: { p_obj_drc->p_state->persistent_ptr = (UWORD8 *)p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX] + - sizeof(ia_drc_state_struct); + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_state_struct), BYTE_ALIGN_8); error_code = impd_drc_set_struct_pointer(p_obj_drc); if (error_code) return error_code; @@ -507,12 +474,92 @@ IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, WORD32 i_cmd, return IA_NO_ERROR; } +static WORD32 impd_calc_scratch_size() { + return IXHEAAC_GET_SIZE_ALIGNED( + AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * NUM_ELE_IN_CPLX_NUM * sizeof(FLOAT32), + BYTE_ALIGN_8); +} + +static WORD32 impd_calc_pers_size() { + WORD32 size = 0; + + WORD32 analysis_buf_size = IXHEAAC_GET_SIZE_ALIGNED( + AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM, + BYTE_ALIGN_8); + WORD32 synth_buf_size = IXHEAAC_GET_SIZE_ALIGNED( + AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM, + BYTE_ALIGN_8); + WORD32 peak_lim_buf_size = IXHEAAC_GET_SIZE_ALIGNED( + AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM, + BYTE_ALIGN_8); + WORD32 subband_buf_size = + NUM_ELE_IN_CPLX_NUM * + IXHEAAC_GET_SIZE_ALIGNED(MAX_CHANNEL_COUNT * sizeof(FLOAT32 *), BYTE_ALIGN_8) + + NUM_ELE_IN_CPLX_NUM * MAX_CHANNEL_COUNT * + IXHEAAC_GET_SIZE_ALIGNED((MAX_SUBBAND_DELAY + MAX_DRC_FRAME_SIZE) * sizeof(FLOAT32), + BYTE_ALIGN_8); + + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_state_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_bits_dec_struct), BYTE_ALIGN_8); + size += 2 * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_gain_dec_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_loudness_info_set_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_gain_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_interface_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_config), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_sel_pro_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_sel_proc_params_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_sel_proc_output_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_peak_limiter_struct), BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_qmf_filt_struct), BYTE_ALIGN_8); + size += analysis_buf_size; + size += synth_buf_size; + size += peak_lim_buf_size; + + size += IXHEAAC_GET_SIZE_ALIGNED(MAX_DRC_BS_BUF_SIZE, BYTE_ALIGN_8); + size += IXHEAAC_GET_SIZE_ALIGNED(MAX_DRC_CONFG_BUF_SIZE, BYTE_ALIGN_8); /*DRC Config Bitstream*/ + size += IXHEAAC_GET_SIZE_ALIGNED(MAX_LOUD_INFO_BUF_SIZE, + BYTE_ALIGN_8); /*DRC loudness info Bitstream*/ + size += + IXHEAAC_GET_SIZE_ALIGNED(MAX_INTERFACE_BUF_SIZE, BYTE_ALIGN_8); /*DRC interface Bitstream*/ + + size += NUM_GAIN_DEC_INSTANCES * SEL_DRC_COUNT * + IXHEAAC_GET_SIZE_ALIGNED((sizeof(ia_interp_buf_struct) * MAX_GAIN_ELE_COUNT), + BYTE_ALIGN_8); /*ia_interp_buf_struct*/ + size += NUM_GAIN_DEC_INSTANCES * + IXHEAAC_GET_SIZE_ALIGNED((sizeof(ia_eq_set_struct)), BYTE_ALIGN_8); /*ia_eq_set_struct*/ + + /*non_interleaved_audio*/ + size += NUM_GAIN_DEC_INSTANCES * + IXHEAAC_GET_SIZE_ALIGNED((MAX_CHANNEL_COUNT * sizeof(FLOAT32 *)), BYTE_ALIGN_8); + size += NUM_GAIN_DEC_INSTANCES * MAX_CHANNEL_COUNT * + IXHEAAC_GET_SIZE_ALIGNED((MAX_DRC_FRAME_SIZE * sizeof(FLOAT32)), BYTE_ALIGN_8); + + /*audio_in_out_buf ptr*/ + size += NUM_GAIN_DEC_INSTANCES * + IXHEAAC_GET_SIZE_ALIGNED((MAX_CHANNEL_COUNT * sizeof(FLOAT32 *)), BYTE_ALIGN_8); + /*audio_io_buffer_delayed*/ + size += NUM_GAIN_DEC_INSTANCES * + IXHEAAC_GET_SIZE_ALIGNED((MAX_CHANNEL_COUNT * sizeof(FLOAT32 *)), BYTE_ALIGN_8); + size += NUM_GAIN_DEC_INSTANCES * MAX_CHANNEL_COUNT * + IXHEAAC_GET_SIZE_ALIGNED((MAX_DRC_FRAME_SIZE * sizeof(FLOAT32)), BYTE_ALIGN_8); + + /*subband band buffer ptr*/ + size += NUM_GAIN_DEC_INSTANCES * NUM_ELE_IN_CPLX_NUM * + IXHEAAC_GET_SIZE_ALIGNED(MAX_CHANNEL_COUNT * sizeof(FLOAT32 *), BYTE_ALIGN_8); + size += NUM_GAIN_DEC_INSTANCES * subband_buf_size; + + size += NUM_GAIN_DEC_INSTANCES * MAX_CHANNEL_COUNT * + IXHEAAC_GET_SIZE_ALIGNED((PARAM_DRC_MAX_BUF_SZ * sizeof(FLOAT32)), BYTE_ALIGN_8); + + return size; +} + IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc) { ia_mem_info_struct *p_mem_info; { p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_PERSIST_IDX]; memset(p_mem_info, 0, sizeof(*p_mem_info)); - p_mem_info->ui_size = PERSIST_MEM_SIZE; + p_mem_info->ui_size = impd_calc_pers_size(); p_mem_info->ui_alignment = 8; p_mem_info->ui_type = IA_MEMTYPE_PERSIST; p_mem_info->ui_placement[0] = 0; @@ -552,7 +599,7 @@ IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc) { { p_mem_info = &p_obj_drc->p_mem_info[IA_DRC_SCRATCH_IDX]; memset(p_mem_info, 0, sizeof(*p_mem_info)); - p_mem_info->ui_size = SCRATCH_MEM_SIZE; + p_mem_info->ui_size = impd_calc_scratch_size(); p_mem_info->ui_alignment = 8; p_mem_info->ui_type = IA_MEMTYPE_SCRATCH; p_mem_info->ui_placement[0] = 0; diff --git a/decoder/drc_src/impd_drc_common.h b/decoder/drc_src/impd_drc_common.h index 324e830..bf0f9dd 100644 --- a/decoder/drc_src/impd_drc_common.h +++ b/decoder/drc_src/impd_drc_common.h @@ -63,15 +63,12 @@ extern "C" { #define NUM_GAIN_DEC_INSTANCES 2 #define MAX_DRC_FRAME_SIZE AUDIO_CODEC_FRAME_SIZE_MAX -#define ANALY_BUF_SIZE \ - (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \ - NUM_ELE_IN_CPLX_NUM) -#define SYNTH_BUF_SIZE \ - (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \ - NUM_ELE_IN_CPLX_NUM) -#define PEAK_LIM_BUF_SIZE \ - (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * \ - NUM_ELE_IN_CPLX_NUM) +#define ANALY_BUF_SIZE \ + (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM) +#define SYNTH_BUF_SIZE \ + (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM) +#define PEAK_LIM_BUF_SIZE \ + (AUDIO_CODEC_FRAME_SIZE_MAX * MAX_CHANNEL_COUNT * sizeof(FLOAT32) * NUM_ELE_IN_CPLX_NUM) /*7 bits read from the bitstream*/ #define MAX_PARAM_DRC_LOOK_AHEAD_VAL 127 diff --git a/decoder/drc_src/impd_drc_gain_decoder.c b/decoder/drc_src/impd_drc_gain_decoder.c index 2a46c44..b2318ef 100644 --- a/decoder/drc_src/impd_drc_gain_decoder.c +++ b/decoder/drc_src/impd_drc_gain_decoder.c @@ -25,6 +25,7 @@ #include "impd_type_def.h" #include "impd_error_standards.h" #include "impd_drc_extr_delta_coded_info.h" +#include "ixheaac_constants.h" #include "impd_drc_common.h" #include "impd_drc_struct.h" #include "impd_parametric_drc_dec.h" @@ -142,9 +143,9 @@ IA_ERRORCODE impd_init_drc_decode_post_config( p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[k] .buf_interpolation = (ia_interp_buf_struct*)*mem_ptr; *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - drc_instruction_str->gain_element_count * - sizeof(ia_interp_buf_struct) + - 32); + IXHEAAC_GET_SIZE_ALIGNED(drc_instruction_str->gain_element_count * + sizeof(ia_interp_buf_struct), + BYTE_ALIGN_8)); p_drc_gain_dec_structs->drc_gain_buffers.pstr_gain_buf[k] .buf_interpolation_count = drc_instruction_str->gain_element_count; for (i = 0; @@ -187,7 +188,8 @@ IA_ERRORCODE impd_init_drc_decode_post_config( } p_drc_gain_dec_structs->eq_set = (ia_eq_set_struct*)*mem_ptr; - *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + sizeof(ia_eq_set_struct)); + *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_eq_set_struct), BYTE_ALIGN_8)); if (err_code) return (err_code); @@ -216,14 +218,23 @@ IA_ERRORCODE impd_init_drc_decode_post_config( } p_drc_gain_dec_structs->audio_band_buffer.non_interleaved_audio = *mem_ptr; - *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (maxMultibandAudioSignalCount * sizeof(FLOAT32*))); + *mem_ptr = + (pVOID)((SIZE_T)*mem_ptr + + IXHEAAC_GET_SIZE_ALIGNED( + (maxMultibandAudioSignalCount * + sizeof(p_drc_gain_dec_structs->audio_band_buffer.non_interleaved_audio[0])), + BYTE_ALIGN_8)); for (i = 0; i < maxMultibandAudioSignalCount; i++) { p_drc_gain_dec_structs->audio_band_buffer.non_interleaved_audio[i] = *mem_ptr; - *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (p_drc_params_struct->drc_frame_size * sizeof(FLOAT32))); + *mem_ptr = + (pVOID)((SIZE_T)*mem_ptr + + IXHEAAC_GET_SIZE_ALIGNED( + (p_drc_params_struct->drc_frame_size * + sizeof( + p_drc_gain_dec_structs->audio_band_buffer.non_interleaved_audio[i][0])), + BYTE_ALIGN_8)); } p_drc_gain_dec_structs->audio_band_buffer.multiband_audio_sig_count = maxMultibandAudioSignalCount; @@ -234,18 +245,25 @@ IA_ERRORCODE impd_init_drc_decode_post_config( if (p_drc_params_struct->sub_band_domain_mode == SUBBAND_DOMAIN_MODE_OFF && p_audio_in_out_buf->audio_delay_samples) { p_audio_in_out_buf->audio_io_buffer_delayed = *mem_ptr; - *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (p_audio_in_out_buf->audio_num_chan * sizeof(FLOAT32*))); + *mem_ptr = + (pVOID)((SIZE_T)*mem_ptr + + IXHEAAC_GET_SIZE_ALIGNED((p_audio_in_out_buf->audio_num_chan * + sizeof(p_audio_in_out_buf->audio_io_buffer_delayed[0])), + BYTE_ALIGN_8)); p_audio_in_out_buf->audio_in_out_buf = *mem_ptr; *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (p_audio_in_out_buf->audio_num_chan * sizeof(FLOAT32*))); + IXHEAAC_GET_SIZE_ALIGNED((p_audio_in_out_buf->audio_num_chan * + sizeof(p_audio_in_out_buf->audio_in_out_buf[0])), + BYTE_ALIGN_8)); for (i = 0; i < p_audio_in_out_buf->audio_num_chan; i++) { p_audio_in_out_buf->audio_io_buffer_delayed[i] = *mem_ptr; *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - ((p_audio_in_out_buf->frame_size + - p_audio_in_out_buf->audio_delay_samples) * - sizeof(FLOAT32*))); + IXHEAAC_GET_SIZE_ALIGNED( + ((p_audio_in_out_buf->frame_size + + p_audio_in_out_buf->audio_delay_samples) * + sizeof(p_audio_in_out_buf->audio_io_buffer_delayed[i][0])), + BYTE_ALIGN_8)); p_audio_in_out_buf->audio_in_out_buf[i] = &p_audio_in_out_buf->audio_io_buffer_delayed [i][p_audio_in_out_buf->audio_delay_samples]; @@ -254,29 +272,43 @@ IA_ERRORCODE impd_init_drc_decode_post_config( if (p_drc_params_struct->sub_band_domain_mode != SUBBAND_DOMAIN_MODE_OFF && p_audio_in_out_buf->audio_delay_sub_band_samples) { p_audio_in_out_buf->audio_buffer_delayed_real = *mem_ptr; - *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (p_audio_in_out_buf->audio_num_chan * sizeof(FLOAT32*))); + *mem_ptr = + (pVOID)((SIZE_T)*mem_ptr + IXHEAAC_GET_SIZE_ALIGNED( + (p_audio_in_out_buf->audio_num_chan * + sizeof(p_audio_in_out_buf->audio_buffer_delayed_real[0])), + BYTE_ALIGN_8)); p_audio_in_out_buf->audio_buffer_delayed_imag = *mem_ptr; - *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (p_audio_in_out_buf->audio_num_chan * sizeof(FLOAT32*))); + *mem_ptr = + (pVOID)((SIZE_T)*mem_ptr + IXHEAAC_GET_SIZE_ALIGNED( + (p_audio_in_out_buf->audio_num_chan * + sizeof(p_audio_in_out_buf->audio_buffer_delayed_imag[0])), + BYTE_ALIGN_8)); p_audio_in_out_buf->audio_real_buff = *mem_ptr; *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (p_audio_in_out_buf->audio_num_chan * sizeof(FLOAT32*))); + IXHEAAC_GET_SIZE_ALIGNED((p_audio_in_out_buf->audio_num_chan * + sizeof(p_audio_in_out_buf->audio_real_buff[0])), + BYTE_ALIGN_8)); p_audio_in_out_buf->audio_imag_buff = *mem_ptr; *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - (p_audio_in_out_buf->audio_num_chan * sizeof(FLOAT32*))); + IXHEAAC_GET_SIZE_ALIGNED((p_audio_in_out_buf->audio_num_chan * + sizeof(p_audio_in_out_buf->audio_imag_buff[0])), + BYTE_ALIGN_8)); for (i = 0; i < p_audio_in_out_buf->audio_num_chan; i++) { p_audio_in_out_buf->audio_buffer_delayed_real[i] = *mem_ptr; *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - ((p_audio_in_out_buf->audio_sub_band_frame_size + - p_audio_in_out_buf->audio_delay_sub_band_samples) * - sizeof(FLOAT32*))); + IXHEAAC_GET_SIZE_ALIGNED( + ((p_audio_in_out_buf->audio_sub_band_frame_size + + p_audio_in_out_buf->audio_delay_sub_band_samples) * + sizeof(p_audio_in_out_buf->audio_buffer_delayed_real[i][0])), + BYTE_ALIGN_8)); p_audio_in_out_buf->audio_buffer_delayed_imag[i] = *mem_ptr; *mem_ptr = (pVOID)((SIZE_T)*mem_ptr + - ((p_audio_in_out_buf->audio_sub_band_frame_size + - p_audio_in_out_buf->audio_delay_sub_band_samples) * - sizeof(FLOAT32*))); + IXHEAAC_GET_SIZE_ALIGNED( + ((p_audio_in_out_buf->audio_sub_band_frame_size + + p_audio_in_out_buf->audio_delay_sub_band_samples) * + sizeof(p_audio_in_out_buf->audio_buffer_delayed_imag[i][0])), + BYTE_ALIGN_8)); p_audio_in_out_buf->audio_real_buff[i] = &p_audio_in_out_buf->audio_buffer_delayed_real @@ -377,7 +409,6 @@ IA_ERRORCODE impd_drc_process_time_domain( return err_code; } - VOID impd_get_parametric_drc_delay( ia_drc_gain_dec_struct* p_drc_gain_dec_structs, ia_drc_config* pstr_drc_config, WORD32* parametric_drc_delay, diff --git a/decoder/drc_src/impd_drc_init.c b/decoder/drc_src/impd_drc_init.c index cf232e8..870b759 100644 --- a/decoder/drc_src/impd_drc_init.c +++ b/decoder/drc_src/impd_drc_init.c @@ -24,6 +24,7 @@ #include "impd_error_standards.h" #include #include "impd_drc_extr_delta_coded_info.h" +#include "ixheaac_constants.h" #include "impd_drc_common.h" #include "impd_drc_struct.h" #include "impd_drc_interface.h" @@ -281,73 +282,65 @@ IA_ERRORCODE impd_drc_set_struct_pointer(ia_drc_api_struct *p_obj_drc) { pUWORD8 persistent_ptr = (pUWORD8)p_obj_drc->p_state->persistent_ptr; UWORD64 persistent_size_consumed = 0; - p_obj_drc->str_payload.pstr_bitstream_dec = - (ia_drc_bits_dec_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_bits_dec_struct); + p_obj_drc->str_payload.pstr_bitstream_dec = (ia_drc_bits_dec_struct *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_bits_dec_struct), BYTE_ALIGN_8); - p_obj_drc->str_payload.pstr_gain_dec[0] = - (ia_drc_gain_dec_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_gain_dec_struct); + p_obj_drc->str_payload.pstr_gain_dec[0] = (ia_drc_gain_dec_struct *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_gain_dec_struct), BYTE_ALIGN_8); - p_obj_drc->str_payload.pstr_gain_dec[1] = - (ia_drc_gain_dec_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_gain_dec_struct); + p_obj_drc->str_payload.pstr_gain_dec[1] = (ia_drc_gain_dec_struct *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_gain_dec_struct), BYTE_ALIGN_8); - p_obj_drc->str_payload.pstr_loudness_info = - (ia_drc_loudness_info_set_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_loudness_info_set_struct); + p_obj_drc->str_payload.pstr_loudness_info = (ia_drc_loudness_info_set_struct *)persistent_ptr; + persistent_ptr += + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_loudness_info_set_struct), BYTE_ALIGN_8); p_obj_drc->str_payload.pstr_drc_gain = (ia_drc_gain_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_gain_struct); + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_gain_struct), BYTE_ALIGN_8); - p_obj_drc->str_payload.pstr_drc_interface = - (ia_drc_interface_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_interface_struct); + p_obj_drc->str_payload.pstr_drc_interface = (ia_drc_interface_struct *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_interface_struct), BYTE_ALIGN_8); p_obj_drc->str_payload.pstr_drc_config = (ia_drc_config *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_config); + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_config), BYTE_ALIGN_8); - p_obj_drc->str_payload.pstr_selection_proc = - (ia_drc_sel_pro_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_sel_pro_struct); + p_obj_drc->str_payload.pstr_selection_proc = (ia_drc_sel_pro_struct *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_sel_pro_struct), BYTE_ALIGN_8); p_obj_drc->str_bit_handler.it_bit_buf = (UWORD8 *)persistent_ptr; - persistent_ptr += MAX_DRC_BS_BUF_SIZE; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(MAX_DRC_BS_BUF_SIZE, BYTE_ALIGN_8); p_obj_drc->str_payload.pstr_drc_sel_proc_params = (ia_drc_sel_proc_params_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_sel_proc_params_struct); + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_sel_proc_params_struct), BYTE_ALIGN_8); p_obj_drc->str_payload.pstr_drc_sel_proc_output = (ia_drc_sel_proc_output_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_sel_proc_output_struct); + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_sel_proc_output_struct), BYTE_ALIGN_8); p_obj_drc->str_bit_handler.bitstream_drc_config = (UWORD8 *)persistent_ptr; - persistent_ptr += MAX_BS_BUF_SIZE; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(MAX_BS_BUF_SIZE, BYTE_ALIGN_8); p_obj_drc->str_bit_handler.bitstream_loudness_info = (UWORD8 *)persistent_ptr; - persistent_ptr += MAX_BS_BUF_SIZE; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(MAX_BS_BUF_SIZE, BYTE_ALIGN_8); - p_obj_drc->str_bit_handler.bitstream_unidrc_interface = - (UWORD8 *)persistent_ptr; - persistent_ptr += MAX_BS_BUF_SIZE; + p_obj_drc->str_bit_handler.bitstream_unidrc_interface = (UWORD8 *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(MAX_BS_BUF_SIZE, BYTE_ALIGN_8); - p_obj_drc->str_payload.pstr_peak_limiter = - (ia_drc_peak_limiter_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_peak_limiter_struct); + p_obj_drc->str_payload.pstr_peak_limiter = (ia_drc_peak_limiter_struct *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_peak_limiter_struct), BYTE_ALIGN_8); p_obj_drc->str_payload.pstr_peak_limiter->buffer = (FLOAT32 *)persistent_ptr; - persistent_ptr += PEAK_LIM_BUF_SIZE; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(PEAK_LIM_BUF_SIZE, BYTE_ALIGN_8); - p_obj_drc->str_payload.pstr_qmf_filter = - (ia_drc_qmf_filt_struct *)persistent_ptr; - persistent_ptr += sizeof(ia_drc_qmf_filt_struct); + p_obj_drc->str_payload.pstr_qmf_filter = (ia_drc_qmf_filt_struct *)persistent_ptr; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_drc_qmf_filt_struct), BYTE_ALIGN_8); p_obj_drc->str_payload.pstr_qmf_filter->ana_buff = (FLOAT64 *)persistent_ptr; - persistent_ptr += ANALY_BUF_SIZE; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(ANALY_BUF_SIZE, BYTE_ALIGN_8); p_obj_drc->str_payload.pstr_qmf_filter->syn_buff = (FLOAT64 *)persistent_ptr; - persistent_ptr += SYNTH_BUF_SIZE; + persistent_ptr += IXHEAAC_GET_SIZE_ALIGNED(SYNTH_BUF_SIZE, BYTE_ALIGN_8); persistent_size_consumed = (UWORD64)(persistent_ptr - (pUWORD8)p_obj_drc->p_state->persistent_ptr); diff --git a/decoder/drc_src/impd_drc_parametric_dec.c b/decoder/drc_src/impd_drc_parametric_dec.c index 4a42fd6..7222fad 100644 --- a/decoder/drc_src/impd_drc_parametric_dec.c +++ b/decoder/drc_src/impd_drc_parametric_dec.c @@ -23,6 +23,7 @@ #include #include "impd_type_def.h" #include "impd_drc_extr_delta_coded_info.h" +#include "ixheaac_constants.h" #include "impd_drc_common.h" #include "impd_drc_struct.h" #include "impd_parametric_drc_dec.h" @@ -262,8 +263,10 @@ VOID impd_init_parametric_drc_lim( pstr_parametric_lim_type_drc_params->max_buf = (FLOAT32*)(*mem_ptr); *mem_ptr = (pVOID)((SIZE_T)(*mem_ptr) + - pstr_parametric_lim_type_drc_params->num_max_buf_sec * - sec_len * sizeof(FLOAT32)); + IXHEAAC_GET_SIZE_ALIGNED( + pstr_parametric_lim_type_drc_params->num_max_buf_sec * sec_len * + sizeof(pstr_parametric_lim_type_drc_params->max_buf[0]), + BYTE_ALIGN_8)); pstr_parametric_lim_type_drc_params->attack_ms = (FLOAT32)hParametricDrcTypeLimBs->parametric_lim_attack; diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index 066bf9d..b707df0 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -153,17 +153,18 @@ IA_ERRORCODE ixheaacd_dec_mem_api(ia_exhaacplus_dec_api_struct *p_obj_exhaacplus (UWORD32 *)p_obj_exhaacplus_dec->p_mem_info_aac + i_idx; UWORD32 pers_size = meminfo[0]; p_temp = p_temp + pers_size - - (sizeof(ia_dec_data_struct) + - sizeof(ia_audio_specific_config_struct) + (8300)); + (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(MAX_HEADER_BUF_SIZE, BYTE_ALIGN_8)); p_obj_exhaacplus_dec->p_state_aac = pv_value; memset(p_obj_exhaacplus_dec->p_state_aac, 0, - sizeof(ia_aac_dec_state_struct)); + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8)); p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data = p_temp; p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = - p_temp + sizeof(ia_dec_data_struct); + p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8); p_obj_exhaacplus_dec->p_state_aac->header_ptr = - p_temp + sizeof(ia_dec_data_struct) + - sizeof(ia_audio_specific_config_struct); + p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8); } } else { @@ -1117,21 +1118,22 @@ IA_ERRORCODE ixheaacd_decoder_flush_api(ia_exhaacplus_dec_api_struct *p_obj_exha header_temp_ptr = p_obj_exhaacplus_dec->p_state_aac->header_ptr; header_length = p_obj_exhaacplus_dec->p_state_aac->header_length; memset(p_obj_exhaacplus_dec->p_state_aac, 0, - sizeof(ia_aac_dec_state_struct)); + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8)); { pUWORD8 p_temp = (pUWORD8)p_obj_exhaacplus_dec->p_state_aac; UWORD32 *meminfo = (UWORD32 *)p_obj_exhaacplus_dec->p_mem_info_aac; UWORD32 pers_size = meminfo[0]; p_temp = p_temp + pers_size - - (sizeof(ia_dec_data_struct) + - sizeof(ia_audio_specific_config_struct) + (8300)); + (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(MAX_HEADER_BUF_SIZE, BYTE_ALIGN_8)); p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data = p_temp; p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config = - p_temp + sizeof(ia_dec_data_struct); + p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8); p_obj_exhaacplus_dec->p_state_aac->header_ptr = - p_temp + sizeof(ia_dec_data_struct) + - sizeof(ia_audio_specific_config_struct); + p_temp + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8); } memset(&(p_obj_exhaacplus_dec->aac_config), 0, sizeof(ia_aac_dec_config_struct)); @@ -1207,74 +1209,90 @@ ixheaacd_persistent_buffer_sizes(WORD32 num_channel) { WORD32 temp; WORD32 max_channels; - size_buffers += 4 * 512 * num_channel * sizeof(WORD32); + size_buffers += IXHEAAC_GET_SIZE_ALIGNED(4 * 512 * num_channel * sizeof(WORD32), BYTE_ALIGN_8); - size_buffers += (ltp_buffer_size * num_channel * sizeof(WORD16)); + size_buffers += + num_channel * IXHEAAC_GET_SIZE_ALIGNED(ltp_buffer_size * sizeof(WORD16), BYTE_ALIGN_8); - size_buffers += num_channel * sizeof(ia_aac_dec_channel_info); + size_buffers += + num_channel * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_channel_info), BYTE_ALIGN_8); if (num_channel > 2) { max_channels = MAX_BS_ELEMENT; } else { max_channels = 2; } - size_buffers += - (max_channels) * 2 * ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct)); - - size_buffers += ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8); + size_buffers += (max_channels)*2 * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), BYTE_ALIGN_8); - size_buffers += ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8); - - size_buffers += 2 * num_channel * - (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * - sizeof(WORD16); + size_buffers += + num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAXSBRBYTES * sizeof(WORD8), BYTE_ALIGN_8); - size_buffers += 2 * num_channel * - (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * - sizeof(WORD32); + size_buffers += + num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAXSBRBYTES * sizeof(WORD8), BYTE_ALIGN_8); - size_buffers += 2 * num_channel * - (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * - sizeof(WORD16); + size_buffers += + 2 * num_channel * + IXHEAAC_GET_SIZE_ALIGNED( + (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * sizeof(WORD16), BYTE_ALIGN_8); - size_buffers += 2 * num_channel * - (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * - sizeof(WORD32); + size_buffers += + 2 * num_channel * + IXHEAAC_GET_SIZE_ALIGNED( + (QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * sizeof(WORD32), BYTE_ALIGN_8); size_buffers += - num_channel * 2 * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + 2 * num_channel * + IXHEAAC_GET_SIZE_ALIGNED( + (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * sizeof(WORD16), BYTE_ALIGN_8); size_buffers += - 2 * LPC_ORDER * num_channel * NO_ANALYSIS_CHANNELS * sizeof(WORD32); + 2 * num_channel * + IXHEAAC_GET_SIZE_ALIGNED( + (QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * sizeof(WORD32), BYTE_ALIGN_8); - size_buffers += LPC_ORDER * 2 * sizeof(WORD32 *); + size_buffers += num_channel * 2 * + IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32), + BYTE_ALIGN_8); - size_buffers += - 2 * LPC_ORDER * num_channel * NO_ANALYSIS_CHANNELS * sizeof(WORD32); + size_buffers += 2 * LPC_ORDER * num_channel * + IXHEAAC_GET_SIZE_ALIGNED(NO_ANALYSIS_CHANNELS * sizeof(WORD32), BYTE_ALIGN_8); + + size_buffers += 2 * IXHEAAC_GET_SIZE_ALIGNED(LPC_ORDER * sizeof(WORD32 *), BYTE_ALIGN_8); + + size_buffers += 2 * LPC_ORDER * num_channel * + IXHEAAC_GET_SIZE_ALIGNED(NO_ANALYSIS_CHANNELS * sizeof(WORD32), BYTE_ALIGN_8); - size_buffers += num_channel * 3 * 2 * MAX_FREQ_COEFFS * sizeof(WORD16); + size_buffers += 2 * num_channel * 3 * + IXHEAAC_GET_SIZE_ALIGNED(MAX_FREQ_COEFFS * sizeof(WORD16), BYTE_ALIGN_8); - temp = sizeof(ia_freq_band_data_struct) + - sizeof(ia_sbr_prev_frame_data_struct) + sizeof(ia_sbr_channel_struct) + - sizeof(ia_sbr_header_data_struct); - size_buffers += 2 * num_channel * ALIGN_SIZE64(temp); + temp = IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_freq_band_data_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_prev_frame_data_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_channel_struct), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_header_data_struct), BYTE_ALIGN_8); + size_buffers += 2 * num_channel * temp; - size_buffers += MAX_BS_ELEMENT * sizeof(ixheaac_drc_bs_data_struct *); + size_buffers += MAX_BS_ELEMENT * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ixheaac_drc_bs_data_struct *), BYTE_ALIGN_8); - size_buffers += num_channel * sizeof(ia_ps_dec_struct); + size_buffers += num_channel * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_ps_dec_struct), BYTE_ALIGN_8); { WORD32 temp_size = 0; - size_buffers += - (num_channel * (sizeof(ia_sbr_frame_info_data_struct) + - MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8) * 2); - temp_size += sizeof(ia_pvc_data_struct); - temp_size += sizeof(ia_esbr_hbe_txposer_struct) * 2; - temp_size += (MAX_HBE_PERSISTENT_SIZE * 2); - temp_size += (MAX_QMF_BUF_LEN * 2 * 2 * sizeof(FLOAT32 *)); - temp_size += (MAX_QMF_BUF_LEN * MAX_QMF_BUF_LEN * 2 * 2 * sizeof(FLOAT32)); - temp_size += (MAX_ENV_COLS * MAX_QMF_BUF_LEN * 2 * 2 * sizeof(WORD32)); - size_buffers += temp_size * num_channel; + size_buffers += (num_channel * 2 * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8, + BYTE_ALIGN_8)); + temp_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_pvc_data_struct), BYTE_ALIGN_8); + temp_size += 2 * IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8); + temp_size += 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8); + temp_size += + 2 * 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_QMF_BUF_LEN * sizeof(FLOAT32 *), BYTE_ALIGN_8); + temp_size += 2 * 2 * MAX_QMF_BUF_LEN * + IXHEAAC_GET_SIZE_ALIGNED(MAX_QMF_BUF_LEN * sizeof(FLOAT32), BYTE_ALIGN_8); + temp_size += 2 * 2 * MAX_ENV_COLS * + IXHEAAC_GET_SIZE_ALIGNED(MAX_QMF_BUF_LEN * sizeof(WORD32), BYTE_ALIGN_8); + size_buffers += num_channel * temp_size; } return (size_buffers); @@ -1303,13 +1321,15 @@ VOID ixheaacd_fill_aac_mem_tables( p_mem_info_aac = &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX]; p_mem_info_aac->ui_size = - sizeof(ia_aac_dec_state_struct) + - channels * sizeof(struct ia_aac_persistent_struct) + - buffer_size + channels * ixheaacd_getsize_sbr_persistent() + - channels * 16 + ixheaacd_mps_persistent_buffer_sizes(); - p_mem_info_aac->ui_size += sizeof(ia_dec_data_struct); - p_mem_info_aac->ui_size += sizeof(ia_audio_specific_config_struct); - p_mem_info_aac->ui_size += 8300; + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8) + + channels * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_aac_persistent_struct), BYTE_ALIGN_8) + + buffer_size + channels * ixheaacd_getsize_sbr_persistent() + channels * 16 + + ixheaacd_mps_persistent_buffer_sizes(); + p_mem_info_aac->ui_size += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8); + p_mem_info_aac->ui_size += + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_audio_specific_config_struct), BYTE_ALIGN_8); + p_mem_info_aac->ui_size += IXHEAAC_GET_SIZE_ALIGNED(MAX_HEADER_BUF_SIZE, BYTE_ALIGN_8); p_mem_info_aac->ui_alignment = 16; p_mem_info_aac->ui_type = IA_MEMTYPE_PERSIST; } @@ -1572,30 +1592,34 @@ IA_ERRORCODE ixheaacd_dec_init( } if (p_obj_exhaacplus_dec->aac_config.header_dec_done == 0) { WORD32 channels; + UWORD32 total_persistent_used = 0; p_obj_exhaacplus_dec->p_state_aac->p_config = &p_obj_exhaacplus_dec->aac_config; p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr = - (pVOID)((SIZE_T)((pWORD8)p_obj_exhaacplus_dec->p_state_aac + - sizeof(ia_aac_dec_state_struct) + sizeof(SIZE_T) - 1) & - (SIZE_T)(~(sizeof(SIZE_T) - 1))); + (pVOID)((pWORD8)p_obj_exhaacplus_dec->p_state_aac + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_state_struct), BYTE_ALIGN_8)); if (p_obj_exhaacplus_dec->aac_config.ui_max_channels > 2) { p_state_enhaacplus_dec->aac_persistent_mem_v = (pVOID)((pWORD8)p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr + (MAX_BS_ELEMENT)*2 * - ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), + BYTE_ALIGN_8)); memset(p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr, 0, (MAX_BS_ELEMENT)*2 * - ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), BYTE_ALIGN_8)); } else { - p_state_enhaacplus_dec->aac_persistent_mem_v = (pVOID)( - (pWORD8)p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr + - (2) * 2 * ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + p_state_enhaacplus_dec->aac_persistent_mem_v = + (pVOID)((pWORD8)p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr + + (2) * 2 * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), + BYTE_ALIGN_8)); memset(p_obj_exhaacplus_dec->p_state_aac->pstr_stream_sbr, 0, - (2) * 2 * ALIGN_SIZE64(sizeof(ia_aac_dec_sbr_bitstream_struct))); + (2) * 2 * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_sbr_bitstream_struct), BYTE_ALIGN_8)); } if (1 == p_obj_exhaacplus_dec->aac_config.ui_max_channels) channels = 1; @@ -1606,9 +1630,9 @@ IA_ERRORCODE ixheaacd_dec_init( p_state_enhaacplus_dec->aac_persistent_mem_v, channels); p_state_enhaacplus_dec->sbr_persistent_mem_v = - (pVOID)((SIZE_T)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + - persistent_used + sizeof(SIZE_T) - 1) & - (SIZE_T)(~(sizeof(SIZE_T) - 1))); + (pVOID)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + + IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8)); + total_persistent_used += IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8); persistent_used = ixheaacd_getsize_sbr_persistent(); ixheaacd_set_sbr_persistent_buffers( @@ -1616,15 +1640,21 @@ IA_ERRORCODE ixheaacd_dec_init( channels, 1); p_state_enhaacplus_dec->heaac_mps_handle.mps_persistent_mem_v = - (pVOID)((SIZE_T)((pWORD8)p_state_enhaacplus_dec->sbr_persistent_mem_v + - persistent_used + sizeof(SIZE_T) - 1) & - (SIZE_T)(~(sizeof(SIZE_T) - 1))); + (pVOID)((pWORD8)p_state_enhaacplus_dec->sbr_persistent_mem_v + + IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8)); + total_persistent_used += IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8); persistent_used = ixheaacd_getsize_mps_persistent(); ixheaacd_set_mps_persistent_buffers( &p_state_enhaacplus_dec->heaac_mps_handle, &persistent_used, channels, p_state_enhaacplus_dec->heaac_mps_handle.mps_persistent_mem_v); + total_persistent_used += IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8); + + if (total_persistent_used > + p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_PERSIST_IDX].ui_size) { + return IA_XHEAAC_DEC_INIT_FATAL_DEC_INIT_FAIL; + } aac_persistent_mem = (struct ia_aac_persistent_struct *) p_state_enhaacplus_dec->aac_persistent_mem_v; diff --git a/decoder/ixheaacd_cnst.h b/decoder/ixheaacd_cnst.h index a83f48e..417551a 100644 --- a/decoder/ixheaacd_cnst.h +++ b/decoder/ixheaacd_cnst.h @@ -119,4 +119,6 @@ #define SFB_PER_PRED_BAND 2 +#define MAX_HEADER_BUF_SIZE 8300 + #endif /* IXHEAACD_CNST_H */ diff --git a/decoder/ixheaacd_common_initfuncs.c b/decoder/ixheaacd_common_initfuncs.c index 47d0994..f7278be 100644 --- a/decoder/ixheaacd_common_initfuncs.c +++ b/decoder/ixheaacd_common_initfuncs.c @@ -105,9 +105,8 @@ VOID ixheaacd_allocate_mem_persistent( *sbr_persistent_start = *persistent_used_total; p_state_enhaacplus_dec->sbr_persistent_mem_v = - (pVOID)((SIZE_T)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + - persistent_used + sizeof(SIZE_T) - 1) & - (SIZE_T)(~(sizeof(SIZE_T) - 1))); + (pVOID)((pWORD8)p_state_enhaacplus_dec->aac_persistent_mem_v + + IXHEAAC_GET_SIZE_ALIGNED(persistent_used, BYTE_ALIGN_8)); persistent_used = ixheaacd_getsize_sbr_persistent(); diff --git a/decoder/ixheaacd_create.c b/decoder/ixheaacd_create.c index 4866fe1..8b65947 100644 --- a/decoder/ixheaacd_create.c +++ b/decoder/ixheaacd_create.c @@ -503,7 +503,7 @@ WORD32 ixheaacd_frm_data_init(ia_audio_specific_config_struct *pstr_audio_conf, WORD32 stream_count = 1; WORD32 max_layer = -1; - memset(pstr_dec_data, 0, sizeof(ia_dec_data_struct)); + memset(pstr_dec_data, 0, IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_dec_data_struct), BYTE_ALIGN_8)); memset(&(pstr_dec_data->str_frame_data), 0, sizeof(pstr_dec_data->str_frame_data)); diff --git a/decoder/ixheaacd_initfuncs.c b/decoder/ixheaacd_initfuncs.c index a96fb96..66b297a 100644 --- a/decoder/ixheaacd_initfuncs.c +++ b/decoder/ixheaacd_initfuncs.c @@ -98,34 +98,47 @@ WORD32 ixheaacd_set_aac_persistent_buffers(VOID *aac_persistent_mem_v, struct ia_aac_persistent_struct *aac_persistent_mem = (struct ia_aac_persistent_struct *)aac_persistent_mem_v; - persistent_used = sizeof(struct ia_aac_persistent_struct); + persistent_used = + IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_aac_persistent_struct), BYTE_ALIGN_8); - memset(aac_persistent_mem, 0, sizeof(struct ia_aac_persistent_struct)); + memset(aac_persistent_mem, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_aac_persistent_struct), BYTE_ALIGN_8)); aac_persistent_mem->overlap_buffer = (WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used); - memset((WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, - 4 * 512 * num_channel * sizeof(WORD32)); + memset( + (WORD32 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, + IXHEAAC_GET_SIZE_ALIGNED( + 4 * 512 * num_channel * sizeof(aac_persistent_mem->overlap_buffer[0]), BYTE_ALIGN_8)); - persistent_used += 4 * 512 * num_channel * sizeof(WORD32); + persistent_used += IXHEAAC_GET_SIZE_ALIGNED( + 4 * 512 * num_channel * sizeof(aac_persistent_mem->overlap_buffer[0]), BYTE_ALIGN_8); aac_persistent_mem->sbr_payload_buffer = (WORD8 *)((WORD8 *)aac_persistent_mem_v + persistent_used); memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, - ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8)); + num_channel * + IXHEAAC_GET_SIZE_ALIGNED( + MAXSBRBYTES * sizeof(aac_persistent_mem->sbr_payload_buffer[0]), BYTE_ALIGN_8)); - persistent_used += ALIGN_SIZE64(MAXSBRBYTES) * num_channel * sizeof(WORD8); + persistent_used += + num_channel * + IXHEAAC_GET_SIZE_ALIGNED(MAXSBRBYTES * sizeof(aac_persistent_mem->sbr_payload_buffer[0]), + BYTE_ALIGN_8); aac_persistent_mem->prev_sbr_payload_buffer = (WORD8 *)((WORD8 *)aac_persistent_mem_v + persistent_used); memset((WORD8 *)aac_persistent_mem->prev_sbr_payload_buffer, 0, - ALIGN_SIZE64(MAXSBRBYTES) * num_channel * - sizeof(*(aac_persistent_mem->prev_sbr_payload_buffer))); + num_channel * IXHEAAC_GET_SIZE_ALIGNED( + MAXSBRBYTES * sizeof(*(aac_persistent_mem->prev_sbr_payload_buffer)), + BYTE_ALIGN_8)); - persistent_used += ALIGN_SIZE64(MAXSBRBYTES) * num_channel * - sizeof(*(aac_persistent_mem->prev_sbr_payload_buffer)); + persistent_used += + num_channel * + IXHEAAC_GET_SIZE_ALIGNED( + MAXSBRBYTES * sizeof(*(aac_persistent_mem->prev_sbr_payload_buffer)), BYTE_ALIGN_8); { WORD32 i; @@ -135,14 +148,15 @@ WORD32 ixheaacd_set_aac_persistent_buffers(VOID *aac_persistent_mem_v, (WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used); memset((WORD16 *)((WORD8 *)aac_persistent_mem_v + persistent_used), 0, - ltp_buffer_size * sizeof(WORD16)); + IXHEAAC_GET_SIZE_ALIGNED(ltp_buffer_size * sizeof(aac_persistent_mem->ltp_buf[i][0]), + BYTE_ALIGN_8)); - persistent_used += (ltp_buffer_size * sizeof(WORD16)); + persistent_used += IXHEAAC_GET_SIZE_ALIGNED( + ltp_buffer_size * sizeof(aac_persistent_mem->ltp_buf[i][0]), BYTE_ALIGN_8); aac_persistent_mem->ptr_aac_dec_static_channel_info[i] = - (ia_aac_dec_channel_info *)((WORD8 *)aac_persistent_mem_v + - persistent_used); - persistent_used += sizeof(ia_aac_dec_channel_info); + (ia_aac_dec_channel_info *)((WORD8 *)aac_persistent_mem_v + persistent_used); + persistent_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_aac_dec_channel_info), BYTE_ALIGN_8); aac_persistent_mem->ptr_aac_dec_static_channel_info[i] ->overlap_add_data.win_shape = 0; @@ -407,7 +421,8 @@ ia_aac_decoder_struct *ixheaacd_aac_decoder_init( { WORD32 *ptr_overlap_buf = aac_dec_handle->pstr_aac_dec_overlap_info[ch]->ptr_overlap_buf; - memset(ptr_overlap_buf, 0, sizeof(WORD32) * 4 * 512); + memset(ptr_overlap_buf, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ptr_overlap_buf[0]) * 4 * 512, BYTE_ALIGN_8)); } aac_persistent_mem->str_aac_decoder.ptr_aac_dec_static_channel_info[ch] = aac_persistent_mem->ptr_aac_dec_static_channel_info[ch]; diff --git a/decoder/ixheaacd_mps_initfuncs.c b/decoder/ixheaacd_mps_initfuncs.c index dfae106..535d672 100644 --- a/decoder/ixheaacd_mps_initfuncs.c +++ b/decoder/ixheaacd_mps_initfuncs.c @@ -67,7 +67,9 @@ #define ALIGN_SIZE32(x) ((((x) + 3) >> 2) << 2) -WORD32 ixheaacd_getsize_mps_persistent() { return (ALIGN_SIZE64(sizeof(ia_mps_persistent_mem))); } +WORD32 ixheaacd_getsize_mps_persistent() { + return (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_persistent_mem), BYTE_ALIGN_8)); +} static WORD32 ixheaacd_calc_decorr_size() { WORD32 matrix_alloc_size, decorr_filter_size, num_den_size; @@ -75,25 +77,31 @@ static WORD32 ixheaacd_calc_decorr_size() { WORD32 state_alloc_size, alloc_size, dec_type = 0; matrix_alloc_size = - 2 * (MAX_HYBRID_BANDS * (MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY) * sizeof(WORD32) + - MAX_HYBRID_BANDS * sizeof(VOID *)) * - MAX_NO_DECORR_CHANNELS; - decorr_filter_size = MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS * - sizeof(ia_mps_dec_decorr_filter_instance_struct); - num_den_size = - (MAX_NUM_DEN_LENGTH) * sizeof(WORD32) * MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS; + MAX_NO_DECORR_CHANNELS * 2 * + (MAX_HYBRID_BANDS * + IXHEAAC_GET_SIZE_ALIGNED((MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY) * sizeof(WORD32), + BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(MAX_HYBRID_BANDS * sizeof(WORD32 *), BYTE_ALIGN_8)); + decorr_filter_size = + MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_decorr_filter_instance_struct), BYTE_ALIGN_8); + num_den_size = MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS * + IXHEAAC_GET_SIZE_ALIGNED(MAX_NUM_DEN_LENGTH * sizeof(WORD32), BYTE_ALIGN_8); if (dec_type == 1) fraction_alloc_size = 4 * num_den_size; else fraction_alloc_size = 2 * num_den_size; - state_alloc_size = - 2 * (MAX_NUM_DEN_LENGTH) * sizeof(WORD32) * MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS; + state_alloc_size = MAX_NO_DECORR_CHANNELS * MAX_HYBRID_BANDS * 2 * + IXHEAAC_GET_SIZE_ALIGNED(MAX_NUM_DEN_LENGTH * sizeof(WORD32), BYTE_ALIGN_8); - ducker_create_size = MAX_NO_DECORR_CHANNELS * (sizeof(ia_mps_dec_ducker_interface) + - sizeof(ia_mps_dec_duck_instance_struct)); - decor_dec_size = sizeof(ia_mps_dec_decorr_dec_struct) * MAX_NO_DECORR_CHANNELS; + ducker_create_size = + MAX_NO_DECORR_CHANNELS * + (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_ducker_interface), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_duck_instance_struct), BYTE_ALIGN_8)); + decor_dec_size = MAX_NO_DECORR_CHANNELS * + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_decorr_dec_struct), BYTE_ALIGN_8); alloc_size = matrix_alloc_size + decorr_filter_size + fraction_alloc_size + ducker_create_size + decor_dec_size + state_alloc_size; @@ -104,49 +112,50 @@ static WORD32 ixheaacd_calc_decorr_size() { WORD32 ixheaacd_mps_persistent_buffer_sizes() { WORD32 buffer_size; - buffer_size = sizeof(ia_heaac_mps_state_struct); + buffer_size = ixheaacd_getsize_mps_persistent(); - buffer_size += PREV_GAINAT; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(PREV_GAINAT, BYTE_ALIGN_8); - buffer_size += ARBDMX_ALPHA; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(ARBDMX_ALPHA, BYTE_ALIGN_8); - buffer_size += M1_PREV; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8); - buffer_size += M1_PREV; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8); - buffer_size += M2_PREV_DECOR; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8); - buffer_size += M2_PREV_DECOR; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8); - buffer_size += M2_PREV_RESID; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8); - buffer_size += M2_PREV_RESID; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8); - buffer_size += QMF_DELAY_INPUT; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8); - buffer_size += QMF_DELAY_INPUT; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8); - buffer_size += ANA_BUF_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(ANA_BUF_SIZE, BYTE_ALIGN_8); - buffer_size += SYN_BUF_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(SYN_BUF_SIZE, BYTE_ALIGN_8); buffer_size += ixheaacd_calc_decorr_size(); - buffer_size += HYB_FILTER_STATE_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(HYB_FILTER_STATE_SIZE, BYTE_ALIGN_8); - buffer_size += TONALITY_STATE_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(TONALITY_STATE_SIZE, BYTE_ALIGN_8); - buffer_size += SMOOTHING_STATE_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(SMOOTHING_STATE_SIZE, BYTE_ALIGN_8); - buffer_size += RESHAPE_STATE_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(RESHAPE_STATE_SIZE, BYTE_ALIGN_8); - buffer_size += SUBBAND_TP_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(SUBBAND_TP_SIZE, BYTE_ALIGN_8); - buffer_size += BLIND_DECODER_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(BLIND_DECODER_SIZE, BYTE_ALIGN_8); - buffer_size += sizeof(ia_mps_dec_spatial_bs_frame_struct); + buffer_size += + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_spatial_bs_frame_struct), BYTE_ALIGN_8); - buffer_size += ARRAY_STRUCT_SIZE; + buffer_size += IXHEAAC_GET_SIZE_ALIGNED(ARRAY_STRUCT_SIZE, BYTE_ALIGN_8); return buffer_size; } @@ -164,57 +173,69 @@ VOID ixheaacd_set_mps_persistent_buffers(ia_heaac_mps_state_struct *pstr_mps_sta mps_persistent_mem->prev_gain_at = (WORD32 *)((WORD8 *)persistent_mem); - memset(mps_persistent_mem->prev_gain_at, 0, PREV_GAINAT); + memset(mps_persistent_mem->prev_gain_at, 0, + IXHEAAC_GET_SIZE_ALIGNED(PREV_GAINAT, BYTE_ALIGN_8)); - used_persistent += PREV_GAINAT; + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(PREV_GAINAT, BYTE_ALIGN_8); mps_persistent_mem->arbdmx_alpha_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->arbdmx_alpha_prev, 0, ARBDMX_ALPHA); - used_persistent += ARBDMX_ALPHA; + memset(mps_persistent_mem->arbdmx_alpha_prev, 0, + IXHEAAC_GET_SIZE_ALIGNED(ARBDMX_ALPHA, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(ARBDMX_ALPHA, BYTE_ALIGN_8); mps_persistent_mem->m1_param_real_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->m1_param_real_prev, 0, M1_PREV); - used_persistent += M1_PREV; + memset(mps_persistent_mem->m1_param_real_prev, 0, + IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8); mps_persistent_mem->m1_param_imag_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->m1_param_imag_prev, 0, M1_PREV); - used_persistent += M1_PREV; + memset(mps_persistent_mem->m1_param_imag_prev, 0, + IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M1_PREV, BYTE_ALIGN_8); mps_persistent_mem->m2_decor_real_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->m2_decor_real_prev, 0, M2_PREV_DECOR); - used_persistent += M2_PREV_DECOR; + memset(mps_persistent_mem->m2_decor_real_prev, 0, + IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8); mps_persistent_mem->m2_decor_imag_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->m2_decor_imag_prev, 0, M2_PREV_DECOR); - used_persistent += M2_PREV_DECOR; + memset(mps_persistent_mem->m2_decor_imag_prev, 0, + IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_DECOR, BYTE_ALIGN_8); mps_persistent_mem->m2_resid_real_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->m2_resid_real_prev, 0, M2_PREV_RESID); - used_persistent += M2_PREV_RESID; + memset(mps_persistent_mem->m2_resid_real_prev, 0, + IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8); mps_persistent_mem->m2_resid_imag_prev = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->m2_resid_imag_prev, 0, M2_PREV_RESID); - used_persistent += M2_PREV_RESID; + memset(mps_persistent_mem->m2_resid_imag_prev, 0, + IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(M2_PREV_RESID, BYTE_ALIGN_8); mps_persistent_mem->qmf_input_delay_real = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->qmf_input_delay_real, 0, QMF_DELAY_INPUT); - used_persistent += QMF_DELAY_INPUT; + memset(mps_persistent_mem->qmf_input_delay_real, 0, + IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8); mps_persistent_mem->qmf_input_delay_imag = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->qmf_input_delay_imag, 0, QMF_DELAY_INPUT); - used_persistent += QMF_DELAY_INPUT; + memset(mps_persistent_mem->qmf_input_delay_imag, 0, + IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(QMF_DELAY_INPUT, BYTE_ALIGN_8); mps_persistent_mem->syn_qmf_states_buffer = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->syn_qmf_states_buffer, 0, SYN_BUF_SIZE); - used_persistent += SYN_BUF_SIZE; + memset(mps_persistent_mem->syn_qmf_states_buffer, 0, + IXHEAAC_GET_SIZE_ALIGNED(SYN_BUF_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(SYN_BUF_SIZE, BYTE_ALIGN_8); mps_persistent_mem->ana_qmf_states_buffer = (WORD32 *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->ana_qmf_states_buffer, 0, ANA_BUF_SIZE); - used_persistent += ANA_BUF_SIZE; + memset(mps_persistent_mem->ana_qmf_states_buffer, 0, + IXHEAAC_GET_SIZE_ALIGNED(ANA_BUF_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(ANA_BUF_SIZE, BYTE_ALIGN_8); decorr_size = ixheaacd_calc_decorr_size(); @@ -224,43 +245,52 @@ VOID ixheaacd_set_mps_persistent_buffers(ia_heaac_mps_state_struct *pstr_mps_sta mps_persistent_mem->hyb_filter_state = (ia_mps_dec_thyb_filter_state_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->hyb_filter_state, 0, HYB_FILTER_STATE_SIZE); - used_persistent += HYB_FILTER_STATE_SIZE; + memset(mps_persistent_mem->hyb_filter_state, 0, + IXHEAAC_GET_SIZE_ALIGNED(HYB_FILTER_STATE_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(HYB_FILTER_STATE_SIZE, BYTE_ALIGN_8); mps_persistent_mem->ton_state = (ia_mps_dec_tonality_state_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->ton_state, 0, TONALITY_STATE_SIZE); - used_persistent += TONALITY_STATE_SIZE; + memset(mps_persistent_mem->ton_state, 0, + IXHEAAC_GET_SIZE_ALIGNED(TONALITY_STATE_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(TONALITY_STATE_SIZE, BYTE_ALIGN_8); mps_persistent_mem->smooth_state = (ia_mps_dec_smoothing_state_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->smooth_state, 0, SMOOTHING_STATE_SIZE); - used_persistent += SMOOTHING_STATE_SIZE; + memset(mps_persistent_mem->smooth_state, 0, + IXHEAAC_GET_SIZE_ALIGNED(SMOOTHING_STATE_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(SMOOTHING_STATE_SIZE, BYTE_ALIGN_8); mps_persistent_mem->reshape_bb_env_state = (ia_mps_dec_reshape_bb_env_state_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->reshape_bb_env_state, 0, RESHAPE_STATE_SIZE); - used_persistent += RESHAPE_STATE_SIZE; + memset(mps_persistent_mem->reshape_bb_env_state, 0, + IXHEAAC_GET_SIZE_ALIGNED(RESHAPE_STATE_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(RESHAPE_STATE_SIZE, BYTE_ALIGN_8); mps_persistent_mem->sub_band_params = (ia_mps_dec_subband_tp_params_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->sub_band_params, 0, SUBBAND_TP_SIZE); - used_persistent += SUBBAND_TP_SIZE; + memset(mps_persistent_mem->sub_band_params, 0, + IXHEAAC_GET_SIZE_ALIGNED(SUBBAND_TP_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(SUBBAND_TP_SIZE, BYTE_ALIGN_8); mps_persistent_mem->blind_decoder = (ia_mps_dec_blind_decoder_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->blind_decoder, 0, BLIND_DECODER_SIZE); - used_persistent += BLIND_DECODER_SIZE; + memset(mps_persistent_mem->blind_decoder, 0, + IXHEAAC_GET_SIZE_ALIGNED(BLIND_DECODER_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(BLIND_DECODER_SIZE, BYTE_ALIGN_8); mps_persistent_mem->p_bs_frame = (ia_mps_dec_spatial_bs_frame_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(mps_persistent_mem->p_bs_frame, 0, sizeof(ia_mps_dec_spatial_bs_frame_struct)); - used_persistent += sizeof(ia_mps_dec_spatial_bs_frame_struct); + memset(mps_persistent_mem->p_bs_frame, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_spatial_bs_frame_struct), BYTE_ALIGN_8)); + used_persistent += + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_spatial_bs_frame_struct), BYTE_ALIGN_8); pstr_mps_state->array_struct = (ia_mps_dec_reuse_array_struct *)((WORD8 *)persistent_mem + used_persistent); - memset(pstr_mps_state->array_struct, 0, ARRAY_STRUCT_SIZE); - used_persistent += ARRAY_STRUCT_SIZE; + memset(pstr_mps_state->array_struct, 0, + IXHEAAC_GET_SIZE_ALIGNED(ARRAY_STRUCT_SIZE, BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(ARRAY_STRUCT_SIZE, BYTE_ALIGN_8); *persistent_used = used_persistent; } @@ -733,19 +763,24 @@ VOID ixheaacd_decorr_init(ia_heaac_mps_state_struct *pstr_mps_state) { for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) { pstr_mps_state->ap_decor[k] = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(ia_mps_dec_decorr_dec_struct); + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_decorr_dec_struct), BYTE_ALIGN_8); } for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) { pstr_mps_state->ap_decor[k]->ducker = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(ia_mps_dec_ducker_interface) + - sizeof(ia_mps_dec_duck_instance_struct); + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_ducker_interface), BYTE_ALIGN_8) + + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_mps_dec_duck_instance_struct), BYTE_ALIGN_8); } for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) { for (i = 0; i < hybrid_bands; i++) { pstr_mps_state->ap_decor[k]->filter[i] = decorr_persistent; - decorr_persistent = - (WORD8 *)decorr_persistent + sizeof(ia_mps_dec_decorr_filter_instance_struct); + decorr_persistent = (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + sizeof(ia_mps_dec_decorr_filter_instance_struct), BYTE_ALIGN_8); } } @@ -753,22 +788,52 @@ VOID ixheaacd_decorr_init(ia_heaac_mps_state_struct *pstr_mps_state) { for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) { for (i = 0; i < hybrid_bands; i++) { pstr_mps_state->ap_decor[k]->filter[i]->numerator_real = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * + sizeof(pstr_mps_state->ap_decor[k]->filter[i]->numerator_real[0]), + BYTE_ALIGN_8); pstr_mps_state->ap_decor[k]->filter[i]->denominator_real = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * + sizeof(pstr_mps_state->ap_decor[k]->filter[i]->denominator_real[0]), + BYTE_ALIGN_8); pstr_mps_state->ap_decor[k]->filter[i]->numerator_imag = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * + sizeof(pstr_mps_state->ap_decor[k]->filter[i]->numerator_imag[0]), + BYTE_ALIGN_8); pstr_mps_state->ap_decor[k]->filter[i]->denominator_imag = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * + sizeof(pstr_mps_state->ap_decor[k]->filter[i]->denominator_imag[0]), + BYTE_ALIGN_8); } } } else { for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) { for (i = 0; i < hybrid_bands; i++) { pstr_mps_state->ap_decor[k]->filter[i]->numerator_real = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * + sizeof(pstr_mps_state->ap_decor[k]->filter[i]->numerator_real[0]), + BYTE_ALIGN_8); pstr_mps_state->ap_decor[k]->filter[i]->denominator_real = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * + sizeof(pstr_mps_state->ap_decor[k]->filter[i]->denominator_real[0]), + BYTE_ALIGN_8); } } } @@ -776,34 +841,54 @@ VOID ixheaacd_decorr_init(ia_heaac_mps_state_struct *pstr_mps_state) { for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) { for (i = 0; i < hybrid_bands; i++) { pstr_mps_state->ap_decor[k]->filter[i]->state_real = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * sizeof(pstr_mps_state->ap_decor[k]->filter[i]->state_real[0]), + BYTE_ALIGN_8); pstr_mps_state->ap_decor[k]->filter[i]->state_imag = decorr_persistent; - decorr_persistent = (WORD8 *)decorr_persistent + sizeof(WORD32) * MAX_NUM_DEN_LENGTH; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + MAX_NUM_DEN_LENGTH * sizeof(pstr_mps_state->ap_decor[k]->filter[i]->state_imag[0]), + BYTE_ALIGN_8); } } for (k = 0; k < MAX_NO_DECORR_CHANNELS; k++) { - pstr_mps_state->ap_decor[k]->delay_buffer_real = - (WORD32 **)ALIGN_SIZE64((SIZE_T)(decorr_persistent)); - decorr_persistent = (WORD8 *)decorr_persistent + 8 * hybrid_bands; + pstr_mps_state->ap_decor[k]->delay_buffer_real = (WORD32 **)decorr_persistent; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + hybrid_bands * sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_real[0]), + BYTE_ALIGN_8); for (i = 0; i < hybrid_bands; i++) { - pstr_mps_state->ap_decor[k]->delay_buffer_real[i] = - (WORD32 *)ALIGN_SIZE64((SIZE_T)(decorr_persistent)); + pstr_mps_state->ap_decor[k]->delay_buffer_real[i] = (WORD32 *)decorr_persistent; - decorr_persistent = - (WORD8 *)decorr_persistent + 4 * (MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY); + decorr_persistent = (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + (MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY) * + sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_real[i][0]), + BYTE_ALIGN_8); } pstr_mps_state->ap_decor[k]->delay_buffer_imag = (WORD32 **)ALIGN_SIZE64((SIZE_T)(decorr_persistent)); - decorr_persistent = (WORD8 *)decorr_persistent + 8 * hybrid_bands; + decorr_persistent = + (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + hybrid_bands * sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_imag[0]), + BYTE_ALIGN_8); for (i = 0; i < hybrid_bands; i++) { pstr_mps_state->ap_decor[k]->delay_buffer_imag[i] = (WORD32 *)ALIGN_SIZE64((SIZE_T)(decorr_persistent)); - decorr_persistent = - (WORD8 *)decorr_persistent + 4 * (MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY); + decorr_persistent = (WORD8 *)decorr_persistent + + IXHEAAC_GET_SIZE_ALIGNED( + (MAX_TIME_SLOTS + MAX_NO_TIME_SLOTS_DELAY) * + sizeof(pstr_mps_state->ap_decor[k]->delay_buffer_imag[i][0]), + BYTE_ALIGN_8); } } } diff --git a/decoder/ixheaacd_sbrdec_initfuncs.c b/decoder/ixheaacd_sbrdec_initfuncs.c index 7205fa2..cfc991d 100644 --- a/decoder/ixheaacd_sbrdec_initfuncs.c +++ b/decoder/ixheaacd_sbrdec_initfuncs.c @@ -81,7 +81,7 @@ extern const WORD32 ixheaacd_ldmps_polyphase_filter_coeff_fix[1280]; #define FD_OVERSAMPLING_FAC (1.5f) WORD32 ixheaacd_getsize_sbr_persistent() { - return (ALIGN_SIZE64(sizeof(ia_sbr_pers_struct))); + return (IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_pers_struct), BYTE_ALIGN_8)); } VOID ixheaacd_esbr_hbe_data_init( @@ -93,7 +93,8 @@ VOID ixheaacd_esbr_hbe_data_init( WORD32 used_persistent = 0; if (pstr_esbr_hbe_txposer) { - memset(pstr_esbr_hbe_txposer, 0, sizeof(ia_esbr_hbe_txposer_struct)); + memset(pstr_esbr_hbe_txposer, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8)); pstr_esbr_hbe_txposer->core_frame_length = num_aac_samples; @@ -169,35 +170,41 @@ VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, &sbr_persistent_mem->str_sbr_dec_inst; num_channel = max(2, num_channel); - memset(sbr_persistent_mem, 0, sizeof(struct ia_sbr_pers_struct)); + memset(sbr_persistent_mem, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(struct ia_sbr_pers_struct), BYTE_ALIGN_8)); sbr_persistent_mem->sbr_qmf_analy_states = (WORD16 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - temp = num_channel * ((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * - sizeof(WORD16)); + temp = num_channel * + IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * + sizeof(sbr_persistent_mem->sbr_qmf_analy_states[0]), + BYTE_ALIGN_8); used_persistent += temp; sbr_persistent_mem->sbr_qmf_analy_states_32 = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - temp1 = - num_channel * - ((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * sizeof(WORD32)); + temp1 = num_channel * + IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_ANA_SIZE + 2 * NO_ANALYSIS_CHANNELS) * + sizeof(sbr_persistent_mem->sbr_qmf_analy_states_32[0]), + BYTE_ALIGN_8); used_persistent += temp1; sbr_persistent_mem->sbr_qmf_synth_states = (WORD16 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - temp2 = - (num_channel * ((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * - sizeof(WORD16))); + temp2 = (num_channel * + IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * + sizeof(sbr_persistent_mem->sbr_qmf_synth_states[0]), + BYTE_ALIGN_8)); used_persistent += temp2; sbr_persistent_mem->sbr_qmf_synth_states_32 = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - temp3 = - (num_channel * ((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * - sizeof(WORD32))); + temp3 = (num_channel * + IXHEAAC_GET_SIZE_ALIGNED((QMF_FILTER_STATE_SYN_SIZE + 2 * NO_SYNTHESIS_CHANNELS) * + sizeof(sbr_persistent_mem->sbr_qmf_synth_states_32[0]), + BYTE_ALIGN_8)); used_persistent += temp3; memset(sbr_persistent_mem->sbr_qmf_analy_states, 0, @@ -208,14 +215,24 @@ VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); if (ps_enable) { - memset(sbr_persistent_mem->ptr_sbr_overlap_buf[i], 0, - 2 * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32)); + memset( + sbr_persistent_mem->ptr_sbr_overlap_buf[i], 0, + 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * + sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), + BYTE_ALIGN_8)); used_persistent += - 2 * MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + 2 * IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * + sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), + BYTE_ALIGN_8); } else { memset(sbr_persistent_mem->ptr_sbr_overlap_buf[i], 0, - MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32)); - used_persistent += MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * sizeof(WORD32); + IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * + sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), + BYTE_ALIGN_8)); + used_persistent += + IXHEAAC_GET_SIZE_ALIGNED(MAX_OV_COLS * NO_SYNTHESIS_CHANNELS * + sizeof(sbr_persistent_mem->ptr_sbr_overlap_buf[i][0]), + BYTE_ALIGN_8); } } @@ -223,15 +240,21 @@ VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, WORD32 j; sbr_persistent_mem->sbr_lpc_filter_states_real[i] = (WORD32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += LPC_ORDER * sizeof(WORD32 *); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + LPC_ORDER * sizeof(sbr_persistent_mem->sbr_lpc_filter_states_real[i][0]), BYTE_ALIGN_8); for (j = 0; j < LPC_ORDER; j++) { sbr_persistent_mem->sbr_lpc_filter_states_real[i][j] = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += NO_ANALYSIS_CHANNELS * sizeof(WORD32); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + NO_ANALYSIS_CHANNELS * sizeof(sbr_persistent_mem->sbr_lpc_filter_states_real[i][j][0]), + BYTE_ALIGN_8); memset(sbr_persistent_mem->sbr_lpc_filter_states_real[i][j], 0, - NO_ANALYSIS_CHANNELS * sizeof(WORD32)); + IXHEAAC_GET_SIZE_ALIGNED( + NO_ANALYSIS_CHANNELS * + sizeof(sbr_persistent_mem->sbr_lpc_filter_states_real[i][j][0]), + BYTE_ALIGN_8)); } } @@ -241,15 +264,22 @@ VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, sbr_persistent_mem->sbr_lpc_filter_states_imag[i] = (WORD32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += LPC_ORDER * sizeof(WORD32 *); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + LPC_ORDER * sizeof(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][0]), BYTE_ALIGN_8); for (j = 0; j < LPC_ORDER; j++) { sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j] = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += NO_ANALYSIS_CHANNELS * sizeof(WORD32); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + NO_ANALYSIS_CHANNELS * + sizeof(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j][0]), + BYTE_ALIGN_8); memset(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j], 0, - NO_ANALYSIS_CHANNELS * sizeof(WORD32)); + IXHEAAC_GET_SIZE_ALIGNED( + NO_ANALYSIS_CHANNELS * + sizeof(sbr_persistent_mem->sbr_lpc_filter_states_imag[i][j][0]), + BYTE_ALIGN_8)); } } } @@ -259,32 +289,35 @@ VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, sbr_persistent_mem->sbr_smooth_gain_buf[i] = (WORD16 *)((WORD8 *)sbr_persistent_mem_v + temp_used); - temp_used += 2 * MAX_FREQ_COEFFS * sizeof(WORD16); + temp_used += 2 * IXHEAAC_GET_SIZE_ALIGNED( + MAX_FREQ_COEFFS * sizeof(sbr_persistent_mem->sbr_smooth_gain_buf[i][0]), + BYTE_ALIGN_8); sbr_persistent_mem->sbr_smooth_noise_buf[i] = (WORD16 *)((WORD8 *)sbr_persistent_mem_v + temp_used); - temp_used += MAX_FREQ_COEFFS * sizeof(WORD16); + temp_used += IXHEAAC_GET_SIZE_ALIGNED( + MAX_FREQ_COEFFS * sizeof(sbr_persistent_mem->sbr_smooth_noise_buf[i][0]), BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_freq_band_data[i] = (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); - temp_used += ALIGN_SIZE64(sizeof(ia_freq_band_data_struct)); + temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_freq_band_data_struct), BYTE_ALIGN_8); sbr_persistent_mem->pstr_prev_frame_data[i] = (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); - temp_used += ALIGN_SIZE64(sizeof(ia_sbr_prev_frame_data_struct)); + temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_prev_frame_data_struct), BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_channel[i] = (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); - temp_used += ALIGN_SIZE64(sizeof(ia_sbr_channel_struct)); + temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_channel_struct), BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_header[i] = (VOID *)((WORD8 *)sbr_persistent_mem_v + temp_used); - temp_used += ALIGN_SIZE64(sizeof(ia_sbr_header_data_struct)); + temp_used += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_header_data_struct), BYTE_ALIGN_8); memset(sbr_persistent_mem->sbr_smooth_gain_buf[i], 0, temp_used - initial_used); @@ -296,96 +329,138 @@ VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, p_str_sbr_dec_inst->pstr_ps_stereo_dec = (ia_ps_dec_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->pstr_ps_stereo_dec, 0, sizeof(ia_ps_dec_struct)); + memset(p_str_sbr_dec_inst->pstr_ps_stereo_dec, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_ps_dec_struct), BYTE_ALIGN_8)); - used_persistent += sizeof(ia_ps_dec_struct); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_ps_dec_struct), BYTE_ALIGN_8); } p_str_sbr_dec_inst->frame_buffer[0] = (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); memset(p_str_sbr_dec_inst->frame_buffer[0], 0, - (sizeof(ia_sbr_frame_info_data_struct) + - MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8)); - used_persistent = used_persistent + (sizeof(ia_sbr_frame_info_data_struct) + - MAX_FREQ_COEFFS * sizeof(WORD32) + 8); + IXHEAAC_GET_SIZE_ALIGNED( + sizeof(ia_sbr_frame_info_data_struct) + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8, + BYTE_ALIGN_8)); + used_persistent = + used_persistent + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) + 8, + BYTE_ALIGN_8); p_str_sbr_dec_inst->frame_buffer[1] = (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); memset(p_str_sbr_dec_inst->frame_buffer[1], 0, - (sizeof(ia_sbr_frame_info_data_struct) + - MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8)); - used_persistent = used_persistent + (sizeof(ia_sbr_frame_info_data_struct) + - MAX_FREQ_COEFFS * sizeof(WORD32) + 8); + IXHEAAC_GET_SIZE_ALIGNED( + sizeof(ia_sbr_frame_info_data_struct) + MAX_FREQ_COEFFS * sizeof(WORD32) * 2 + 8, + BYTE_ALIGN_8)); + used_persistent = + used_persistent + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_sbr_frame_info_data_struct) + + MAX_FREQ_COEFFS * sizeof(WORD32) + 8, + BYTE_ALIGN_8); { WORD32 index = 0; p_str_sbr_dec_inst->ptr_pvc_data_str = (ia_pvc_data_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->ptr_pvc_data_str, 0, sizeof(ia_pvc_data_struct)); - used_persistent += sizeof(ia_pvc_data_struct); + memset(p_str_sbr_dec_inst->ptr_pvc_data_str, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_pvc_data_struct), BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_pvc_data_struct), BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_hbe_txposer = - (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + - used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_hbe_txposer, - 0, sizeof(ia_esbr_hbe_txposer_struct)); - used_persistent += sizeof(ia_esbr_hbe_txposer_struct); + (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_hbe_txposer, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8); if (num_channel == 2) { p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_hbe_txposer = - (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + - used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_hbe_txposer, - 0, sizeof(ia_esbr_hbe_txposer_struct)); - used_persistent += sizeof(ia_esbr_hbe_txposer_struct); + (ia_esbr_hbe_txposer_struct *)((WORD8 *)sbr_persistent_mem_v + used_persistent); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_hbe_txposer, 0, + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8)); + used_persistent += + IXHEAAC_GET_SIZE_ALIGNED(sizeof(ia_esbr_hbe_txposer_struct), BYTE_ALIGN_8); } p_str_sbr_dec_inst->hbe_txposer_buffers = (VOID *)((WORD8 *)sbr_persistent_mem_v + used_persistent); memset(p_str_sbr_dec_inst->hbe_txposer_buffers, 0, - num_channel * MAX_HBE_PERSISTENT_SIZE); - used_persistent += num_channel * MAX_HBE_PERSISTENT_SIZE; + num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8)); + used_persistent += + num_channel * IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real = (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real, - 0, MAX_QMF_BUF_LEN * sizeof(FLOAT32 *)); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + memset( + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real, 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real[0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real[0]), + BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag = (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag, - 0, MAX_QMF_BUF_LEN); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + memset( + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag, 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag[0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag[0]), + BYTE_ALIGN_8); if (num_channel == 2) { p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real = (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); memset( - p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real, - 0, MAX_QMF_BUF_LEN * sizeof(FLOAT32 *)); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real, 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real[0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_real[0]), + BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag = (FLOAT32 **)((WORD8 *)sbr_persistent_mem_v + used_persistent); memset( - p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag, - 0, MAX_QMF_BUF_LEN * sizeof(FLOAT32 *)); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32 *); + p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag, 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag[0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.pp_qmf_buf_imag[0]), + BYTE_ALIGN_8); } for (index = 0; index < MAX_QMF_BUF_LEN; index++) { p_str_sbr_dec_inst->pstr_sbr_channel[0] ->str_sbr_dec.pp_qmf_buf_real[index] = (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof( + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_real[index][0]), + BYTE_ALIGN_8); } for (index = 0; index < MAX_QMF_BUF_LEN; index++) { p_str_sbr_dec_inst->pstr_sbr_channel[0] ->str_sbr_dec.pp_qmf_buf_imag[index] = (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof( + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.pp_qmf_buf_imag[index][0]), + BYTE_ALIGN_8); } if (num_channel == 2) { @@ -393,46 +468,76 @@ VOID ixheaacd_set_sbr_persistent_buffers(VOID *sbr_persistent_mem_v, p_str_sbr_dec_inst->pstr_sbr_channel[1] ->str_sbr_dec.pp_qmf_buf_real[index] = (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.pp_qmf_buf_real[index][0]), + BYTE_ALIGN_8); } for (index = 0; index < MAX_QMF_BUF_LEN; index++) { p_str_sbr_dec_inst->pstr_sbr_channel[1] ->str_sbr_dec.pp_qmf_buf_imag[index] = (FLOAT32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - used_persistent += MAX_QMF_BUF_LEN * sizeof(FLOAT32); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.pp_qmf_buf_imag[index][0]), + BYTE_ALIGN_8); } } - for (i = 0; i < MAX_ENV_COLS; i++) - { + for (i = 0; i < MAX_ENV_COLS; i++) { p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_real[i] = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_real[i], - 0, MAX_QMF_BUF_LEN * sizeof(WORD32)); - used_persistent += MAX_QMF_BUF_LEN * sizeof(WORD32); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_real[i], 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0] + ->str_sbr_dec.p_arr_qmf_buf_real[i][0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof( + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_real[i][0]), + BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_imag[i] = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_imag[i], - 0, MAX_QMF_BUF_LEN * sizeof(WORD32)); - used_persistent += MAX_QMF_BUF_LEN * sizeof(WORD32); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_imag[i], 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[0] + ->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * + sizeof( + p_str_sbr_dec_inst->pstr_sbr_channel[0]->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), + BYTE_ALIGN_8); } if (num_channel == 2) { - for (i = 0; i < MAX_ENV_COLS; i++) - { + for (i = 0; i < MAX_ENV_COLS; i++) { p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_real[i] = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_real[i], - 0, MAX_QMF_BUF_LEN * sizeof(WORD32)); - used_persistent += MAX_QMF_BUF_LEN * sizeof(WORD32); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_real[i], 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.p_arr_qmf_buf_real[i][0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.p_arr_qmf_buf_real[i][0]), + BYTE_ALIGN_8); p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_imag[i] = (WORD32 *)((WORD8 *)sbr_persistent_mem_v + used_persistent); - memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_imag[i], - 0, MAX_QMF_BUF_LEN * sizeof(WORD32)); - used_persistent += MAX_QMF_BUF_LEN * sizeof(WORD32); + memset(p_str_sbr_dec_inst->pstr_sbr_channel[1]->str_sbr_dec.p_arr_qmf_buf_imag[i], 0, + IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), + BYTE_ALIGN_8)); + used_persistent += IXHEAAC_GET_SIZE_ALIGNED( + MAX_QMF_BUF_LEN * sizeof(p_str_sbr_dec_inst->pstr_sbr_channel[1] + ->str_sbr_dec.p_arr_qmf_buf_imag[i][0]), + BYTE_ALIGN_8); } } } @@ -594,8 +699,8 @@ ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr( sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1 ? 1 : 0, output_frame_size, hbe_txposer_buffers, &persistant_used); - hbe_txposer_buffers = - (WORD8 *)hbe_txposer_buffers + MAX_HBE_PERSISTENT_SIZE; + hbe_txposer_buffers = (WORD8 *)hbe_txposer_buffers + + IXHEAAC_GET_SIZE_ALIGNED(MAX_HBE_PERSISTENT_SIZE, BYTE_ALIGN_8); ixheaacd_esbr_hbe_data_init(ptr_sbr_dec[1]->p_hbe_txposer, samp_per_frame, sbr_ratio_idx == SBR_UPSAMPLE_IDX_4_1 ? 1 : 0,