Collected Cleanups from Ittiam

Test: CTS android.media.cts.DecoderTest{AacDrc,XheAac}

Added __ARM_NEON__ check to generic function selector

Bug: 80432407
Change-Id: I66c7879fda1369da88ccaea5f8792ea54657cdaf

Added support to build for mips

Bug: 80432286
Change-Id: I908029bbaddd3c1fbc39be1192926b56d981576e

Add optimized versions for qmf_dec for armv7 and armv8

Separating common functions and platform specific functions
in ixheaacd_qmf_dec.c. Platform specific functions are moved
to qmf_dec in armv7, armv8 and generic folder.

Bug: 80431870
Change-Id: I860cb79a1870e228d2108b7915418e1c003cefc5

Fixes for crashes reported by Fuzzer tool

Bug: 109697676
Change-Id: I862fc054b99ee9d427d20596bc8d2e85522a7188
This commit is contained in:
Harish Mahendrakar 2018-05-09 14:23:00 -07:00 committed by Ray Essick
parent 36ef96da45
commit 8eb646f89b
33 changed files with 2427 additions and 4163 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,355 @@
/******************************************************************************
* *
* Copyright (C) 2018 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 <string.h>
#include "ixheaacd_sbr_common.h"
#include <ixheaacd_type_def.h>
#include "ixheaacd_constants.h"
#include "ixheaacd_basic_ops32.h"
#include "ixheaacd_basic_ops16.h"
#include "ixheaacd_basic_ops40.h"
#include "ixheaacd_basic_ops.h"
#include "ixheaacd_intrinsics.h"
#include "ixheaacd_common_rom.h"
#include "ixheaacd_bitbuffer.h"
#include "ixheaacd_sbrdecsettings.h"
#include "ixheaacd_sbr_scale.h"
#include "ixheaacd_lpp_tran.h"
#include "ixheaacd_env_extr_part.h"
#include "ixheaacd_sbr_rom.h"
#include "ixheaacd_hybrid.h"
#include "ixheaacd_ps_dec.h"
#include "ixheaacd_env_extr.h"
#include "ixheaacd_qmf_dec.h"
#include <ixheaacd_basic_op.h>
#include "ixheaacd_env_calc.h"
#include "ixheaacd_interface.h"
#include "ixheaacd_function_selector.h"
#include "ixheaacd_audioobjtypes.h"
#define mult16x16_16(a, b) ixheaacd_mult16((a), (b))
#define mac16x16(a, b, c) ixheaacd_mac16x16in32((a), (b), (c))
#define mpy_32x16(a, b) fixmuldiv2_32x16b((a), (b))
#define mpy_16x16(a, b) ixheaacd_mult16x16in32((a), (b))
#define mpy_32x32(a, b) ixheaacd_mult32((a), (b))
#define mpy_32x16H_n(a, b) ixheaacd_mult32x16hin32((a), (b))
#define msu16x16(a, b, c) msu16x16in32((a), (b), (c))
#define DCT3_LEN (32)
#define DCT2_LEN (64)
#define LP_SHIFT_VAL 7
#define HQ_SHIFT_64 4
#define RADIXSHIFT 1
#define ROUNDING_SPECTRA 1
#define HQ_SHIFT_VAL 4
VOID ixheaacd_dct2_64(WORD32 *x, WORD32 *X,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
WORD16 *filter_states) {
ixheaacd_pretwdct2(x, X);
ixheaacd_sbr_imdct_using_fft(qmf_dec_tables_ptr->w1024, 32, X, x,
qmf_dec_tables_ptr->dig_rev_table2_128,
qmf_dec_tables_ptr->dig_rev_table2_128,
qmf_dec_tables_ptr->dig_rev_table2_128,
qmf_dec_tables_ptr->dig_rev_table2_128);
ixheaacd_fftposttw(x, qmf_dec_tables_ptr);
ixheaacd_posttwdct2(x, filter_states, qmf_dec_tables_ptr);
return;
}
VOID ixheaacd_cplx_anal_qmffilt(const WORD16 *time_sample_buf,
ia_sbr_scale_fact_struct *sbr_scale_factor,
WORD32 **qmf_real, WORD32 **qmf_imag,
ia_sbr_qmf_filter_bank_struct *qmf_bank,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
WORD32 ch_fac, WORD32 low_pow_flag,
WORD audio_object_type) {
WORD32 i, k;
WORD32 num_time_slots = qmf_bank->num_time_slots;
WORD32 analysis_buffer[4 * NO_ANALYSIS_CHANNELS];
WORD16 *filter_states = qmf_bank->core_samples_buffer;
WORD16 *fp1, *fp2, *tmp;
WORD16 *filter_1;
WORD16 *filter_2;
WORD16 *filt_ptr;
if (audio_object_type != AOT_ER_AAC_ELD &&
audio_object_type != AOT_ER_AAC_LD) {
qmf_bank->filter_pos +=
(qmf_dec_tables_ptr->qmf_c - qmf_bank->analy_win_coeff);
qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c;
} else {
qmf_bank->filter_pos +=
(qmf_dec_tables_ptr->qmf_c_eld3 - qmf_bank->analy_win_coeff);
qmf_bank->analy_win_coeff = qmf_dec_tables_ptr->qmf_c_eld3;
}
filter_1 = qmf_bank->filter_pos;
if (audio_object_type != AOT_ER_AAC_ELD &&
audio_object_type != AOT_ER_AAC_LD) {
filter_2 = filter_1 + 64;
} else {
filter_2 = filter_1 + 32;
}
sbr_scale_factor->st_lb_scale = 0;
sbr_scale_factor->lb_scale = -10;
if (!low_pow_flag) {
if (audio_object_type != AOT_ER_AAC_ELD &&
audio_object_type != AOT_ER_AAC_LD) {
sbr_scale_factor->lb_scale = -8;
} else {
sbr_scale_factor->lb_scale = -9;
}
qmf_bank->cos_twiddle =
(WORD16 *)qmf_dec_tables_ptr->sbr_sin_cos_twiddle_l32;
qmf_bank->alt_sin_twiddle =
(WORD16 *)qmf_dec_tables_ptr->sbr_alt_sin_twiddle_l32;
if (audio_object_type != AOT_ER_AAC_ELD &&
audio_object_type != AOT_ER_AAC_LD) {
qmf_bank->t_cos = (WORD16 *)qmf_dec_tables_ptr->sbr_t_cos_sin_l32;
} else {
qmf_bank->t_cos =
(WORD16 *)qmf_dec_tables_ptr->ixheaacd_sbr_t_cos_sin_l32_eld;
}
}
fp1 = qmf_bank->anal_filter_states;
fp2 = qmf_bank->anal_filter_states + NO_ANALYSIS_CHANNELS;
if (audio_object_type == AOT_ER_AAC_ELD ||
audio_object_type == AOT_ER_AAC_LD) {
filter_2 = qmf_bank->filter_2;
fp1 = qmf_bank->fp1_anal;
fp2 = qmf_bank->fp2_anal;
}
for (i = 0; i < num_time_slots; i++) {
for (k = 0; k < NO_ANALYSIS_CHANNELS; k++)
filter_states[NO_ANALYSIS_CHANNELS - 1 - k] = time_sample_buf[ch_fac * k];
if (audio_object_type != AOT_ER_AAC_ELD &&
audio_object_type != AOT_ER_AAC_LD) {
ixheaacd_sbr_qmfanal32_winadds(fp1, fp2, filter_1, filter_2,
analysis_buffer, filter_states,
time_sample_buf, ch_fac);
} else {
ixheaacd_sbr_qmfanal32_winadds_eld(fp1, fp2, filter_1, filter_2,
analysis_buffer, filter_states,
time_sample_buf, ch_fac);
}
time_sample_buf += NO_ANALYSIS_CHANNELS * ch_fac;
filter_states -= NO_ANALYSIS_CHANNELS;
if (filter_states < qmf_bank->anal_filter_states) {
filter_states = qmf_bank->anal_filter_states + 288;
}
tmp = fp1;
fp1 = fp2;
fp2 = tmp;
if (audio_object_type != AOT_ER_AAC_ELD &&
audio_object_type != AOT_ER_AAC_LD) {
filter_1 += 64;
filter_2 += 64;
} else {
filter_1 += 32;
filter_2 += 32;
}
filt_ptr = filter_1;
filter_1 = filter_2;
filter_2 = filt_ptr;
if (audio_object_type != AOT_ER_AAC_ELD &&
audio_object_type != AOT_ER_AAC_LD) {
if (filter_2 > (qmf_bank->analy_win_coeff + 640)) {
filter_1 = (WORD16 *)qmf_bank->analy_win_coeff;
filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 64;
}
} else {
if (filter_2 > (qmf_bank->analy_win_coeff + 320)) {
filter_1 = (WORD16 *)qmf_bank->analy_win_coeff;
filter_2 = (WORD16 *)qmf_bank->analy_win_coeff + 32;
}
}
if (!low_pow_flag) {
ixheaacd_fwd_modulation(analysis_buffer, qmf_real[i], qmf_imag[i],
qmf_bank, qmf_dec_tables_ptr);
} else {
ixheaacd_dct3_32(
(WORD32 *)analysis_buffer, qmf_real[i], qmf_dec_tables_ptr->dct23_tw,
qmf_dec_tables_ptr->post_fft_tbl, qmf_dec_tables_ptr->w_16,
qmf_dec_tables_ptr->dig_rev_table4_16);
}
}
qmf_bank->filter_pos = filter_1;
qmf_bank->core_samples_buffer = filter_states;
if (audio_object_type == AOT_ER_AAC_ELD || audio_object_type == AOT_ER_AAC_LD)
{
qmf_bank->fp1_anal = fp1;
qmf_bank->fp2_anal = fp2;
qmf_bank->filter_2 = filter_2;
}
}
VOID ixheaacd_inv_modulation_lp(WORD32 *qmf_real, WORD16 *filter_states,
ia_sbr_qmf_filter_bank_struct *syn_qmf,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
WORD32 L = syn_qmf->no_channels;
const WORD32 M = (L >> 1);
WORD32 *dct_in = qmf_real;
WORD32 time_out[2 * NO_SYNTHESIS_CHANNELS];
WORD32 ui_rem = ((WORD32)(&time_out[0]) % 8);
WORD32 *ptime_out = (pVOID)((WORD8 *)&time_out[0] + 8 - ui_rem);
if (L == 64)
ixheaacd_dec_DCT2_64_asm(dct_in, ptime_out, qmf_dec_tables_ptr->w1024,
qmf_dec_tables_ptr->dig_rev_table2_128,
qmf_dec_tables_ptr->post_fft_tbl,
qmf_dec_tables_ptr->dct23_tw, filter_states + M);
else
ixheaacd_dct2_32(dct_in, time_out, qmf_dec_tables_ptr, filter_states);
filter_states[3 * M] = 0;
}
VOID ixheaacd_inv_emodulation(
WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr) {
ixheaacd_cos_sin_mod(qmf_real, syn_qmf, (WORD16 *)qmf_dec_tables_ptr->w1024,
(WORD32 *)qmf_dec_tables_ptr->dig_rev_table2_128);
}
VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband,
ia_sbr_qmf_filter_bank_struct *qmf_bank,
WORD32 *p_twiddle, WORD32 *p_dig_rev_tbl) {
WORD32 z;
WORD32 temp[128];
WORD32 scaleshift = 0;
WORD32 M_2;
WORD32 M = ixheaacd_shr32(qmf_bank->no_channels, 1);
const WORD32 *p_sin;
const WORD32 *p_sin_cos;
WORD32 subband_tmp[128];
p_sin_cos = qmf_bank->esbr_cos_twiddle;
ixheaacd_esbr_cos_sin_mod_loop1(subband, M, p_sin_cos, subband_tmp);
M_2 = ixheaacd_shr32(M, 1);
if (M == 32) {
ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 8);
ixheaacd_esbr_radix4bfly(p_twiddle + 48, subband_tmp, 4, 2);
ixheaacd_postradixcompute2(subband, subband_tmp, p_dig_rev_tbl, 32);
ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 8);
ixheaacd_esbr_radix4bfly(p_twiddle + 48, &subband_tmp[64], 4, 2);
ixheaacd_postradixcompute2(&subband[64], &subband_tmp[64], p_dig_rev_tbl,
32);
}
else if (M == 16) {
ixheaacd_esbr_radix4bfly(p_twiddle, subband_tmp, 1, 4);
ixheaacd_postradixcompute4(subband, subband_tmp, p_dig_rev_tbl, 16);
ixheaacd_esbr_radix4bfly(p_twiddle, &subband_tmp[64], 1, 4);
ixheaacd_postradixcompute4(&subband[64], &subband_tmp[64], p_dig_rev_tbl,
16);
}
else if (M == 12) {
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
temp[z] = subband_tmp[2 * z];
temp[12 + z] = subband_tmp[2 * z + 1];
}
ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift);
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
subband[2 * z] = temp[z];
subband[2 * z + 1] = temp[z + 12];
}
scaleshift = 0;
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
temp[z] = subband_tmp[64 + 2 * z];
temp[12 + z] = subband_tmp[64 + 2 * z + 1];
}
ixheaacd_complex_fft_p3(temp, &temp[12], 12, -1, &scaleshift);
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
subband[64 + 2 * z] = temp[z];
subband[64 + 2 * z + 1] = temp[z + 12];
}
}
else {
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
temp[z] = subband_tmp[2 * z];
temp[8 + z] = subband_tmp[2 * z + 1];
}
(*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift);
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
subband[2 * z] = temp[z] << scaleshift;
subband[2 * z + 1] = temp[z + 8] << scaleshift;
}
scaleshift = 0;
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
temp[z] = subband_tmp[64 + 2 * z];
temp[8 + z] = subband_tmp[64 + 2 * z + 1];
}
(*ixheaacd_complex_fft_p2)(temp, &temp[8], 8, -1, &scaleshift);
for (z = 0; z < (qmf_bank->no_channels >> 1); z++) {
subband[64 + 2 * z] = temp[z] << scaleshift;
subband[64 + 2 * z + 1] = temp[8 + z] << scaleshift;
}
}
p_sin = qmf_bank->esbr_alt_sin_twiddle;
ixheaacd_esbr_cos_sin_mod_loop2(subband, p_sin, M);
}

File diff suppressed because it is too large Load diff

View file

@ -62,6 +62,7 @@
#include "ixheaacd_env_calc.h"
#include "ixheaacd_interface.h"
#include "ixheaacd_dsp_fft32x32s.h"
#if !__ARM_NEON__
WORD32 (*ixheaacd_fix_div)(WORD32, WORD32) = &ixheaacd_fix_div_dec;
@ -245,4 +246,7 @@ VOID (*ixheaacd_inv_dit_fft_8pt)
VOID (*ixheaacd_scale_factor_process)
(WORD32 *x_invquant, WORD16 *scale_fact, WORD no_band, WORD8 *width,
WORD32 *scale_tables_ptr, WORD32 total_channels, WORD32 object_type,
WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_dec;
WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_dec;
#endif

View file

@ -506,8 +506,8 @@ WORD32 ixheaacd_acelp_alias_cnx(ia_usac_data_struct *usac_data,
ixheaacd_preemphsis_tool_float(code, TILT_CODE, LEN_SUBFR, tmp);
i = pitch_lag;
if (pitch_lag_frac > 2) i++;
ixheaacd_acelp_pitch_sharpening(code, i);
if(i >= 0)
ixheaacd_acelp_pitch_sharpening(code, i);
index = pstr_td_frame_data->gains[k * 4 + subfr_nb];

View file

@ -20,6 +20,10 @@
#include <math.h>
#include <string.h>
#include <ixheaacd_type_def.h>
#include "ixheaacd_constants.h"
#include <ixheaacd_basic_ops32.h>
#include <ixheaacd_basic_ops16.h>
#include <ixheaacd_basic_ops40.h>
#include "ixheaacd_bitbuffer.h"
#include "ixheaacd_interface.h"
@ -41,6 +45,9 @@
#include "ixheaacd_bit_extract.h"
#include "ixheaacd_error_codes.h"
#define ARITH_ESCAPE 16
UWORD16 ixheaacd_ari_cf_r[3][4] = {
@ -1664,6 +1671,10 @@ VOID ixheaacd_copy_to_bitbuff(ia_bit_buf_struct *it_bit_buff_src,
it_bit_buff_dst->cnt_bits = it_bit_buff_src->cnt_bits;
it_bit_buff_dst->size = it_bit_buff_src->size;
it_bit_buff_dst->max_size = it_bit_buff_src->max_size;
}
static WORD32 ixheaacd_arith_get_context(WORD8 *c_prev, WORD8 *c_pres,
@ -1832,6 +1843,7 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff,
}
if (esc_nb < 0) {
esc_nb = 0;
return -1;
}
}
@ -1871,6 +1883,8 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff,
}
bit_count -= 16 - 2;
if(bit_count > it_bit_buff->cnt_bits)
return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES;
if (bit_count > 0) {
bit_count_5 = bit_count >> 5;
@ -1962,7 +1976,7 @@ static VOID ixheaacd_esc_iquant(WORD32 *q, WORD32 *coef, WORD32 noise_level,
coef[i] = flag * (coef[i] << 1);
}
temp = (fac_fix * coef[i]);
temp = ixheaacd_mult64_sat(fac_fix , (WORD64)coef[i]);
coef[i] = (WORD32)(temp >> 22);
}

View file

@ -158,7 +158,10 @@ VOID ixheaacd_voronoi_idx_dec(WORD32 *kv, WORD32 m, WORD32 *y, WORD32 count) {
}
y[0] += (4 * kv[0] + sum);
z[0] = (y[0] - 2) >> count;
rem1[0] = (y[0] - 2) % m;
if(m != 0)
rem1[0] = (y[0] - 2) % m;
else
rem1[0] = (y[0] - 2);
memcpy(rem2, rem1, 8 * sizeof(WORD32));

View file

@ -324,6 +324,18 @@ static PLATFORM_INLINE WORD64 ixheaacd_mult64(WORD32 a, WORD32 b) {
return (result);
}
static PLATFORM_INLINE WORD64 ixheaacd_mult64_sat(WORD64 a, WORD64 b) {
WORD64 result;
if (a > 0 && b > 0 && a > MAX_64 / b) return MAX_64;
if (a < 0 && b > 0 && a < MIN_64 / b) return MIN_64;
if (a > 0 && b < 0 && b < MIN_64 / a) return MIN_64;
if (a < 0 && b < 0 && a < MAX_64 / b) return MAX_64;
result = a * b;
return (result);
}
static PLATFORM_INLINE WORD64 ixheaacd_add64_sat(WORD64 a, WORD64 b) {
WORD64 result , comp;
result = (a < 0) ? MIN_64 : MAX_64;

View file

@ -82,6 +82,7 @@ typedef struct ia_bit_buf_struct {
UWORD8 *byte_ptr;
UWORD8 *ptr_start;
WORD32 write_bit_count;
WORD32 max_size;
} ia_bit_buf_struct;

View file

@ -139,6 +139,10 @@ ia_bit_buf_struct *ixheaacd_create_bit_buf(ia_bit_buf_struct *it_bit_buff,
it_bit_buff->adts_header_present = 0;
it_bit_buff->protection_absent = 0;
it_bit_buff->pstr_adts_crc_info = &it_bit_buff->str_adts_crc_info;
it_bit_buff->max_size = it_bit_buff->size;
ixheaacd_adts_crc_open(it_bit_buff->pstr_adts_crc_info);
return it_bit_buff;

View file

@ -627,6 +627,6 @@ UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_frame_len_idx,
WORD32 *output_samples,WORD32 *sampling_freq, UWORD32* sample_freq_indx);
WORD32 ixheaacd_config(ia_bit_buf_struct *bit_buff,
ia_usac_config_struct *pstr_usac_conf);
ia_usac_config_struct *pstr_usac_conf, UINT32 *chan);
#endif /* IXHEAACD_CONFIG_H */

View file

@ -256,6 +256,9 @@ WORD32 ixheaacd_decode_init(
usac_data->pstr_usac_winmap[2] = &usac_data->str_eight_short_info;
usac_data->pstr_usac_winmap[3] = &usac_data->str_only_long_info;
usac_data->pstr_usac_winmap[4] = &usac_data->str_only_long_info;
if((usac_data->ccfl != 480) && (usac_data->ccfl != 512) && (usac_data->ccfl != 768) && (usac_data->ccfl != 960) &&(usac_data->ccfl != 1024))
return -1;
ixheaacd_info_init(&ixheaacd_samp_rate_info[usac_data->sampling_rate_idx],
usac_data->ccfl, usac_data->pstr_usac_winmap[0],
usac_data->pstr_usac_winmap[2], usac_data->sfb_width_short,

View file

@ -268,6 +268,7 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer,
delay = ixheaacd_decode_create(
handle, pstr_dec_data,
pstr_dec_data->str_frame_data.scal_out_select + 1);
pstr_dec_data->dec_bit_buf.max_size = handle->p_mem_info_aac[IA_MEMTYPE_INPUT].ui_size;
if (delay == -1) return -1;
*num_channel_out = pstr_dec_data->str_frame_data.scal_out_num_channels;
return 0;
@ -276,13 +277,14 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer,
pstr_dec_data->dec_bit_buf.ptr_bit_buf_base = (UWORD8 *)inbuffer;
pstr_dec_data->dec_bit_buf.size = aac_dec_handle->ui_in_bytes << 3;
pstr_dec_data->dec_bit_buf.ptr_bit_buf_end =
(UWORD8 *)inbuffer + aac_dec_handle->ui_in_bytes;
(UWORD8 *)inbuffer + aac_dec_handle->ui_in_bytes - 1;
pstr_dec_data->dec_bit_buf.ptr_read_next = (UWORD8 *)inbuffer;
pstr_dec_data->dec_bit_buf.bit_pos = 7;
pstr_dec_data->dec_bit_buf.cnt_bits = pstr_dec_data->dec_bit_buf.size;
pstr_dec_data->str_usac_data.usac_flag = aac_dec_handle->usac_flag;
if (pstr_dec_data->dec_bit_buf.size > pstr_dec_data->dec_bit_buf.max_size)
pstr_dec_data->dec_bit_buf.max_size = pstr_dec_data->dec_bit_buf.size;
/* audio pre roll frame parsing*/
do{
@ -319,7 +321,7 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer,
return -1;
/* call codec re-configure*/
err = ixheaacd_config(config_bit_buf, &(pstr_dec_data->str_frame_data.str_audio_specific_config.str_usac_config)/*&pstr_audio_specific_config->str_usac_config*/);
err = ixheaacd_config(config_bit_buf, &(pstr_dec_data->str_frame_data.str_audio_specific_config.str_usac_config),&(pstr_audio_specific_config->channel_configuration)/*&pstr_audio_specific_config->str_usac_config*/);
free(config_bit_buf);
if (err != 0) return -1;
@ -335,7 +337,7 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer,
pstr_dec_data->dec_bit_buf.ptr_bit_buf_base = (UWORD8 *)inbuffer;
pstr_dec_data->dec_bit_buf.size = aac_dec_handle->ui_in_bytes << 3;
pstr_dec_data->dec_bit_buf.ptr_bit_buf_end =
(UWORD8 *)inbuffer + aac_dec_handle->ui_in_bytes;
(UWORD8 *)inbuffer + aac_dec_handle->ui_in_bytes - 1;
pstr_dec_data->dec_bit_buf.ptr_read_next = (UWORD8 *)inbuffer;
pstr_dec_data->dec_bit_buf.bit_pos = 7;
pstr_dec_data->dec_bit_buf.cnt_bits = pstr_dec_data->dec_bit_buf.size;

View file

@ -107,7 +107,7 @@ VOID ixheaacd_huffman_decode(WORD32 it_bit_buff, WORD16 *h_index, WORD16 *len,
*len = length;
}
static VOID ixheaacd_read_esbr_pvc_envelope(ia_pvc_data_struct *ptr_pvc_data,
static WORD32 ixheaacd_read_esbr_pvc_envelope(ia_pvc_data_struct *ptr_pvc_data,
ia_bit_buf_struct *it_bit_buff,
WORD32 indepFlag) {
WORD32 i, j, k;
@ -158,6 +158,10 @@ static VOID ixheaacd_read_esbr_pvc_envelope(ia_pvc_data_struct *ptr_pvc_data,
length = (UWORD8)ixheaacd_read_bits_buf(it_bit_buff, length_bits);
length += 1;
sum_length += length;
if((k+length-1) > PVC_NUM_TIME_SLOTS)
{
return -1;
}
for (j = 1; j < length; j++, k++) {
pvc_id[k] = pvc_id[k - 1];
}
@ -221,6 +225,7 @@ static VOID ixheaacd_read_esbr_pvc_envelope(ia_pvc_data_struct *ptr_pvc_data,
for (i = 0; i < PVC_NUM_TIME_SLOTS; i++) {
ptr_pvc_data->pvc_id[i] = pvc_id[i];
}
return 0;
}
static VOID ixheaacd_pvc_env_dtdf_data(
@ -624,12 +629,13 @@ static WORD16 ixheaacd_read_extn_data(
return 1;
}
VOID ixheaacd_sbr_read_pvc_sce(ia_sbr_frame_info_data_struct *ptr_frame_data,
WORD32 ixheaacd_sbr_read_pvc_sce(ia_sbr_frame_info_data_struct *ptr_frame_data,
ia_bit_buf_struct *it_bit_buff, WORD32 hbe_flag,
ia_pvc_data_struct *ptr_pvc_data,
ia_sbr_tables_struct *ptr_sbr_tables,
ia_sbr_header_data_struct *ptr_header_data) {
WORD32 i;
WORD32 err_code = 0;
ia_env_extr_tables_struct *env_extr_tables_ptr =
ptr_sbr_tables->env_extr_tables_ptr;
WORD32 usac_independency_flag = ptr_frame_data->usac_independency_flag;
@ -651,7 +657,9 @@ VOID ixheaacd_sbr_read_pvc_sce(ia_sbr_frame_info_data_struct *ptr_frame_data,
}
}
ixheaacd_pvc_time_freq_grid_info(it_bit_buff, ptr_frame_data);
err_code = ixheaacd_pvc_time_freq_grid_info(it_bit_buff, ptr_frame_data);
if(err_code)
return err_code;
ptr_pvc_data->prev_sbr_mode = PVC_SBR;
@ -679,6 +687,8 @@ VOID ixheaacd_sbr_read_pvc_sce(ia_sbr_frame_info_data_struct *ptr_frame_data,
ixheaacd_read_sbr_addi_data(ptr_frame_data, ptr_header_data, it_bit_buff);
ptr_frame_data->coupling_mode = COUPLING_OFF;
return 0;
}
WORD8 ixheaacd_sbr_read_sce(ia_sbr_header_data_struct *ptr_header_data,
@ -1442,7 +1452,7 @@ int ixheaacd_extract_frame_info_ld(
return 1;
}
VOID ixheaacd_pvc_time_freq_grid_info(
WORD32 ixheaacd_pvc_time_freq_grid_info(
ia_bit_buf_struct *it_bit_buff,
ia_sbr_frame_info_data_struct *ptr_frame_data) {
WORD32 bs_num_env = 0, bs_num_noise = 0;
@ -1475,7 +1485,8 @@ VOID ixheaacd_pvc_time_freq_grid_info(
} else {
time_border[0] = 0;
}
if(time_border[0] < 0)
return -1;
pvc_time_border[0] = 0;
bs_freq_res[0] = 0;
@ -1528,6 +1539,7 @@ VOID ixheaacd_pvc_time_freq_grid_info(
for (i = 0; i < (bs_num_noise + 1); i++) {
p_frame_info->noise_border_vec[i] = time_border_noise[i];
}
return 0;
}
WORD16 ixheaacd_sbr_time_freq_grid_info(

View file

@ -141,7 +141,7 @@ WORD32 ixheaacd_ssc_huff_dec(ia_huffman_data_type h,
int ixheaacd_extract_frame_info_ld(ia_bit_buf_struct *it_bit_buff,
ia_sbr_frame_info_data_struct *h_frame_data);
VOID ixheaacd_pvc_time_freq_grid_info(
WORD32 ixheaacd_pvc_time_freq_grid_info(
ia_bit_buf_struct *it_bit_buff,
ia_sbr_frame_info_data_struct *ptr_frame_data);

View file

@ -46,7 +46,7 @@
#include "string.h"
VOID ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) {
WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) {
WORD32 idx;
WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size;
WORD32 N = (10 * anal_size);
@ -120,8 +120,10 @@ VOID ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) {
*ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);
*ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);
}
(*ixheaacd_cmplx_anal_fft)(u_in, u_out, anal_size * 2);
if(ixheaacd_cmplx_anal_fft != NULL)
(*ixheaacd_cmplx_anal_fft)(u_in, u_out, anal_size * 2);
else
return -1;
for (k = 0; k < anal_size / 2; k++) {
*(anal_buf + 1) = -*ptr_v++;
@ -136,9 +138,10 @@ VOID ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) {
}
}
}
return 0;
}
VOID ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD32 ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD32 num_columns, FLOAT32 qmf_buf_real[][64],
FLOAT32 qmf_buf_imag[][64]) {
WORD32 i, j, k, l, idx;
@ -159,7 +162,8 @@ VOID ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
(idx + 1) * ptr_hbe_txposer->synth_size;
FLOAT32 *synth_cos_tab = ptr_hbe_txposer->synth_cos_tab;
const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->synth_wind_coeff;
if(ptr_hbe_txposer->k_start < 0)
return -1;
for (k = 0; k < synth_size; k++) {
WORD32 ki = ptr_hbe_txposer->k_start + k;
synth_buf_r[k] = (FLOAT32)(
@ -206,7 +210,10 @@ VOID ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
FLOAT32 *syn_buf = &buffer[kmax];
kmax += synth_size;
(*ixheaacd_real_synth_fft)(synth_buf_r, synth_out, synth_size * 2);
if(ixheaacd_real_synth_fft != NULL)
(*ixheaacd_real_synth_fft)(synth_buf_r, synth_out, synth_size * 2);
else
return -1;
for (k = 0; k < kmax; k++) {
tmp = ((*ptr_u++) * (*synth_cos_tab++));
@ -243,4 +250,5 @@ VOID ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
out_buf[i] = (FLOAT32)accu_r;
}
}
return 0;
}

View file

@ -99,7 +99,7 @@ static FLOAT32 *ixheaacd_map_prot_filter(WORD32 filt_length) {
}
}
VOID ixheaacd_qmf_hbe_data_reinit(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD32 ixheaacd_qmf_hbe_data_reinit(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD16 *p_freq_band_tab[2], WORD16 *p_num_sfb,
WORD32 upsamp_4_flag) {
WORD32 synth_size, sfb, patch, stop_patch;
@ -214,9 +214,14 @@ VOID ixheaacd_qmf_hbe_data_reinit(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
}
}
}
if(ptr_hbe_txposer->k_start < 0)
{
return -1;
}
return 0;
}
VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD32 ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
FLOAT32 qmf_buf_real[][64],
FLOAT32 qmf_buf_imag[][64], WORD32 num_columns,
FLOAT32 pv_qmf_buf_real[][64],
@ -224,6 +229,7 @@ VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD32 pitch_in_bins) {
WORD32 i, qmf_band_idx;
WORD32 qmf_voc_columns = ptr_hbe_txposer->no_bins / 2;
WORD32 err_code = 0;
memcpy(ptr_hbe_txposer->ptr_input_buf,
ptr_hbe_txposer->ptr_input_buf +
@ -239,7 +245,9 @@ VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32));
}
ixheaacd_complex_anal_filt(ptr_hbe_txposer);
err_code = ixheaacd_complex_anal_filt(ptr_hbe_txposer);
if(err_code)
return err_code;
for (i = 0; i < (ptr_hbe_txposer->hbe_qmf_out_len - ptr_hbe_txposer->no_bins);
i++) {
@ -272,6 +280,7 @@ VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
ixheaacd_phase_vocoder_cos_table[qmf_band_idx]);
}
}
return 0;
}
VOID ixheaacd_norm_qmf_in_buf_4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,

View file

@ -604,7 +604,7 @@ WORD32 ixheaacd_ga_hdr_dec(ia_aac_dec_state_struct *aac_state_struct,
ixheaacd_conf_default(&(pstr_audio_specific_config->str_usac_config));
err = ixheaacd_config(it_bit_buff,
&(pstr_audio_specific_config->str_usac_config));
&(pstr_audio_specific_config->str_usac_config),&(pstr_audio_specific_config->channel_configuration));
if (err != 0) return -1;
if (pstr_audio_specific_config->audio_object_type == AOT_USAC) {

View file

@ -249,6 +249,8 @@ WORD32 ixheaacd_ext_element_config(
ixheaacd_read_escape_value(it_bit_buff, &(usac_ext_element_config_length), 4,
8, 16);
if(usac_ext_element_config_length >= 768)
return -1;
flag = ixheaacd_read_bits_buf(it_bit_buff, 1);
@ -366,7 +368,7 @@ VOID ixheaacd_cpe_config(
WORD32 ixheaacd_decoder_config(
ia_bit_buf_struct *it_bit_buff,
ia_usac_decoder_config_struct *pstr_usac_decoder_config,
WORD32 sbr_ratio_index) {
WORD32 sbr_ratio_index, UINT32 *chan) {
UWORD32 elem_idx = 0;
UWORD32 err = 0;
@ -404,6 +406,9 @@ WORD32 ixheaacd_decoder_config(
case ID_USAC_CPE:
ixheaacd_cpe_config(it_bit_buff, pstr_usac_element_config,
sbr_ratio_index);
if (pstr_usac_element_config->stereo_config_index > 1 && *chan <2)
return -1;
break;
case ID_USAC_LFE:
@ -494,7 +499,7 @@ WORD32 ixheaacd_config_extension(
}
WORD32 ixheaacd_config(ia_bit_buf_struct *it_bit_buff,
ia_usac_config_struct *pstr_usac_conf) {
ia_usac_config_struct *pstr_usac_conf, UINT32 *chan) {
WORD32 tmp, err;
err = 0;
@ -534,7 +539,7 @@ WORD32 ixheaacd_config(ia_bit_buf_struct *it_bit_buff,
err = ixheaacd_decoder_config(
it_bit_buff, &(pstr_usac_conf->str_usac_dec_config),
ixheaacd_sbr_ratio(pstr_usac_conf->core_sbr_framelength_index));
ixheaacd_sbr_ratio(pstr_usac_conf->core_sbr_framelength_index),chan);
if (err != 0) return -1;
tmp = ixheaacd_read_bits_buf(it_bit_buff, 1);

View file

@ -413,7 +413,10 @@ WORD32 ixheaacd_lpd_dec(ia_usac_data_struct *usac_data,
} else {
fac_length = len_subfrm / 2;
}
if((pstr_td_frame_data->fac_data[0] < 0) || (pstr_td_frame_data->fac_data[0] > 128))
{
return -1;
}
gain = ixheaacd_pow_10_i_by_128[pstr_td_frame_data->fac_data[0]];
memcpy(ptr_scratch, &pstr_td_frame_data->fac_data[0],
@ -699,6 +702,14 @@ WORD32 ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, WORD32 is_short_flag
for (i = 0; i < num_subfr_by2 + 2; i++) {
tp = pitch[i];
if((i * LEN_SUBFR + MAX_PITCH) < tp)
{
return -1;
}
else if((i * LEN_SUBFR + MAX_PITCH - tp) >= 1883)
{
return -1;
}
if (pitch_gain[i] > 0.0f) {
synth_corr = 0.0f, synth_energy = 1e-6f;
for (k = 0; k < LEN_SUBFR; k++) {

View file

@ -88,6 +88,8 @@
#include "ixheaacd_pvc_dec.h"
#include "ixheaacd_sbr_dec.h"
#include "ixheaacd_error_codes.h"
#define MAXNRSBRELEMENTS 6
VOID ixheaacd_allocate_sbr_scr(ia_sbr_scr_struct *sbr_scratch_struct,
@ -107,7 +109,7 @@ WORD16 ixheaacd_esbr_process(ia_usac_data_struct *usac_data,
ia_bit_buf_struct *it_bit_buff,
WORD32 stereo_config_idx, WORD16 num_channels,
WORD32 audio_object_type) {
WORD16 err_code;
WORD16 err_code = 0;
ia_aac_dec_sbr_bitstream_struct *esbr_bit_str = &usac_data->esbr_bit_str[0];
ia_handle_sbr_dec_inst_struct self = usac_data->pstr_esbr_dec;
@ -164,7 +166,7 @@ static VOID ixheaacd_sbr_ext_data_read(
}
}
static VOID ixheaacd_read_ext_element(
static WORD32 ixheaacd_read_ext_element(
UWORD32 usac_ext_element_default_length,
UWORD32 usac_ext_element_payload_frag, ia_bit_buf_struct *it_bit_buff
,
@ -190,7 +192,8 @@ static VOID ixheaacd_read_ext_element(
pay_load_length = (UWORD32)((WORD32)pay_load_length + val_add - 2);
}
}
if ((it_bit_buff->cnt_bits >> 3) < (WORD32)pay_load_length)
return IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES;
if (pay_load_length > 0) {
if (usac_ext_element_payload_frag)
tmp = ixheaacd_read_bits_buf(it_bit_buff, 2);
@ -212,6 +215,7 @@ static VOID ixheaacd_read_ext_element(
}
}
}
return 0;
}
static VOID ixheaacd_sbr_ele_type_set(
@ -268,6 +272,7 @@ VOID ixheaacd_ms_processing(ia_usac_data_struct *pstr_usac_data) {
WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data,
WORD32 *num_out_channels, VOID *codec_handle) {
WORD32 ele_id = 0;
WORD32 err_code = 0;
ia_aac_dec_state_struct *p_state_aac_dec =
(ia_aac_dec_state_struct *)codec_handle;
@ -308,11 +313,15 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data,
case ID_USAC_CPE:
nr_core_coder_channels = (stereo_config_index == 1) ? 1 : 2;
if((stereo_config_index > 1) && (p_state_aac_dec->num_of_output_ch<2))
return -1;
goto core_data_extracting;
case ID_USAC_LFE:
nr_core_coder_channels = 1;
core_data_extracting:
if(ch_offset >= MAX_NUM_CHANNELS)
return -1;
err = ixheaacd_core_coder_data(ele_id, pstr_usac_data, elem_idx,
&ch_offset, it_bit_buff,
nr_core_coder_channels);
@ -333,10 +342,12 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data,
if ((pstr_usac_data->sbr_ratio_idx > 0) &&
(pstr_usac_data->esbr_bit_str[0].no_elements != 0)) {
ixheaacd_esbr_process(
err_code = ixheaacd_esbr_process(
pstr_usac_data, it_bit_buff, stereo_config_index,
nr_core_coder_channels,
pstr_dec_data->str_usac_data.audio_object_type);
if(err_code < 0)
return err_code;
}
if (stereo_config_index > 0) {
@ -387,11 +398,13 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data,
case ID_USAC_EXT: {
ia_usac_dec_element_config_struct *pusac_element_config =
&pstr_usac_dec_config->str_usac_element_config[elem_idx];
ixheaacd_read_ext_element(pusac_element_config->usac_ext_eleme_def_len,
err = ixheaacd_read_ext_element(pusac_element_config->usac_ext_eleme_def_len,
pusac_element_config->usac_ext_elem_pld_frag,
it_bit_buff,
pstr_usac_dec_config, elem_idx
);
if (err != 0)
return err;
break;
}

File diff suppressed because it is too large Load diff

View file

@ -178,4 +178,43 @@ VOID ixheaacd_cos_sin_mod_loop1(WORD32 *subband, WORD32 M,
VOID ixheaacd_cos_sin_mod_loop2(WORD32 *subband, const WORD16 *p_sin, WORD32 M);
VOID ixheaacd_sbr_qmfsyn64_winadd(WORD16 *tmp1, WORD16 *tmp2, WORD16 *inp1,
WORD16 *sample_buffer, FLAG shift,
WORD32 ch_fac);
VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband,
ia_sbr_qmf_filter_bank_struct *qmf_bank,
WORD32 *p_twiddle, WORD32 *p_dig_rev_tbl);
VOID ixheaacd_inv_modulation_lp(WORD32 *qmf_real, WORD16 *filter_states,
ia_sbr_qmf_filter_bank_struct *syn_qmf,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr);
VOID ixheaacd_sbr_pre_twiddle(WORD32 *p_xre, WORD32 *p_xim,
WORD16 *p_twiddles);
VOID ixheaacd_inv_emodulation(
WORD32 *qmf_real, ia_sbr_qmf_filter_bank_struct *syn_qmf,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr);
VOID ixheaacd_pretwdct2(WORD32 *inp, WORD32 *out_fwd);
VOID ixheaacd_sbr_qmfanal32_winadd_eld(WORD16 *inp1, WORD16 *inp2,
WORD16 *p_qmf1, WORD16 *p_qmf2,
WORD32 *p_out);
VOID ixheaacd_dct2_32(WORD32 *inp, WORD32 *out,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr,
WORD16 *filter_states);
VOID ixheaacd_inv_modulation_lp(WORD32 *qmf_real, WORD16 *filter_states,
ia_sbr_qmf_filter_bank_struct *syn_qmf,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr);
VOID ixheaacd_fftposttw(WORD32 *out,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr);
VOID ixheaacd_posttwdct2(WORD32 *inp, WORD16 *out_fwd,
ia_qmf_dec_tables_struct *qmf_dec_tables_ptr);
#endif

View file

@ -23,9 +23,9 @@
double *ixheaacd_interpo_esbr_fcoff(const double *orig_prot, WORD32 no,
WORD32 lo, WORD32 li);
VOID ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer);
WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer);
VOID ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD32 ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer,
WORD32 num_columns, FLOAT32 qmf_buf_real[][64],
FLOAT32 qmf_buf_imag[][64]);

View file

@ -705,7 +705,7 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data,
op_delay + codec_x_delay + SBR_HF_ADJ_OFFSET);
if (hbe_flag) {
ixheaacd_qmf_hbe_apply(
WORD32 err_code = ixheaacd_qmf_hbe_apply(
ptr_sbr_dec->p_hbe_txposer,
ptr_sbr_dec->qmf_buf_real + (op_delay + SBR_HF_ADJ_OFFSET) +
ESBR_HBE_DELAY_OFFSET,
@ -715,6 +715,8 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data,
ptr_sbr_dec->ph_vocod_qmf_real + (op_delay + SBR_HF_ADJ_OFFSET),
ptr_sbr_dec->ph_vocod_qmf_imag + (op_delay + SBR_HF_ADJ_OFFSET),
ptr_frame_data->pitch_in_bins);
if(err_code)
return err_code;
if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) {
ixheaacd_hbe_repl_spec(
@ -1012,7 +1014,7 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data,
return 0;
}
void ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
WORD32 ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
ia_sbr_header_data_struct *ptr_header_data,
ia_sbr_frame_info_data_struct *ptr_frame_data,
FLAG apply_processing, FLAG low_pow_flag,
@ -1098,7 +1100,7 @@ void ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
op_delay + codec_x_delay + SBR_HF_ADJ_OFFSET);
if (hbe_flag) {
ixheaacd_qmf_hbe_apply(
WORD32 err = ixheaacd_qmf_hbe_apply(
ptr_sbr_dec->p_hbe_txposer,
ptr_sbr_dec->qmf_buf_real + (op_delay + SBR_HF_ADJ_OFFSET) +
ESBR_HBE_DELAY_OFFSET,
@ -1108,6 +1110,8 @@ void ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
ptr_sbr_dec->ph_vocod_qmf_real + (op_delay + SBR_HF_ADJ_OFFSET),
ptr_sbr_dec->ph_vocod_qmf_imag + (op_delay + SBR_HF_ADJ_OFFSET),
ptr_frame_data->pitch_in_bins);
if(err)
return err;
if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) {
ixheaacd_hbe_repl_spec(
@ -1131,7 +1135,7 @@ void ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
mps_sbr_flag, ch_fac);
ptr_frame_data->prev_sbr_mode = sbr_mode;
return;
return 0;
}
WORD32 ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec,

View file

@ -174,7 +174,7 @@ WORD16 ixheaacd_create_sbrdec(
WORD32 ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec,
VOID *p_sbr_frame, VOID *p_sbr_header);
VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer,
WORD32 ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer,
FLOAT32 qmf_buf_real[][64],
FLOAT32 qmf_buf_imag[][64], WORD32 num_columns,
FLOAT32 pv_qmf_buf_real[][64],
@ -204,7 +204,7 @@ VOID ixheaacd_rescale_x_overlap(
ia_sbr_prev_frame_data_struct *ptr_frame_data_prev,
WORD32 **pp_overlap_buffer_real, FLAG low_pow_flag);
VOID ixheaacd_qmf_hbe_data_reinit(
WORD32 ixheaacd_qmf_hbe_data_reinit(
ia_esbr_hbe_txposer_struct *ptr_hbe_transposer_str,
WORD16 *ptr_freq_band_tbl[MAX_FREQ_COEFFS + 1], WORD16 *ptr_num_sf_bands,
WORD32 upsamp_4_flag);
@ -216,14 +216,14 @@ WORD32 ixheaacd_sbr_read_pvc_sce(ia_sbr_frame_info_data_struct *ptr_frame_data,
ia_sbr_tables_struct *sbr_tables_ptr,
ia_sbr_header_data_struct *ptr_header_data);
VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer,
WORD32 ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer,
FLOAT32 qmf_buf_real[][64],
FLOAT32 qmf_buf_imag[][64], WORD32 num_columns,
FLOAT32 pv_qmf_buf_real[][64],
FLOAT32 pv_qmf_buf_imag[][64],
WORD32 pitch_in_bins);
VOID ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
WORD32 ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
ia_sbr_header_data_struct *ptr_header_data,
ia_sbr_frame_info_data_struct *ptr_frame_data,
FLAG apply_processing, FLAG low_pow_flag,

View file

@ -1073,6 +1073,8 @@ WORD32 ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64],
patch = 0;
while (sb < usb) {
if(MAX_NUM_PATCHES <= patch)
return -1;
ptr_frame_data->patch_param.start_subband[patch] = sb;
num_bands_in_patch = goal_sb - sb;
@ -1109,11 +1111,7 @@ WORD32 ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64],
}
if (num_bands_in_patch <= 0) {
if(num_bands_in_patch == 0)
{
return -1;
}
continue;
return -1;
}
for (k2 = sb; k2 < sb + num_bands_in_patch; k2++) {
@ -1246,6 +1244,8 @@ WORD32 ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64],
}
}
ptr_frame_data->patch_param.num_patches = patch;
if(patch >= (MAX_NUM_PATCHES + 1))
return -1;
for (i = 0; i < num_if_bands; i++) {
bw_array_prev[i] = bw_array[i];
}

View file

@ -156,11 +156,13 @@ static WORD32 ixheaacd_sbr_dec_reset(ia_sbr_dec_struct *ptr_sbr_dec,
}
if (hbe_flag && ptr_sbr_dec->p_hbe_txposer != NULL) {
WORD32 k, i;
ixheaacd_qmf_hbe_data_reinit(
WORD32 err = ixheaacd_qmf_hbe_data_reinit(
ptr_sbr_dec->p_hbe_txposer,
ptr_header_data->pstr_freq_band_data->freq_band_table,
ptr_header_data->pstr_freq_band_data->num_sf_bands,
ptr_header_data->is_usf_4);
if(err)
return err;
for (k = 0; k < 2; k++) {
if (!((upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) && (k == 0))) {
@ -178,12 +180,14 @@ static WORD32 ixheaacd_sbr_dec_reset(ia_sbr_dec_struct *ptr_sbr_dec,
64 * sizeof(FLOAT32));
}
ixheaacd_qmf_hbe_apply(
err = ixheaacd_qmf_hbe_apply(
ptr_sbr_dec->p_hbe_txposer,
ptr_sbr_dec->qmf_buf_real + op_delay + xpos_delay,
ptr_sbr_dec->qmf_buf_imag + op_delay + xpos_delay, num_time_slots,
ptr_sbr_dec->ph_vocod_qmf_real + op_delay,
ptr_sbr_dec->ph_vocod_qmf_imag + op_delay, pitch_in_bins);
if(err)
return err;
if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) {
ixheaacd_hbe_repl_spec(&ptr_sbr_dec->p_hbe_txposer->x_over_qmf[0],
@ -436,6 +440,9 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self,
&(pstr_sbr_channel[lr]->str_sbr_dec), ptr_header_data[k],
low_pow_flag, self->pstr_common_tables,
ptr_frame_data[k]->pitch_in_bins, audio_object_type);
if(err < 0)
return err;
}
}
@ -466,6 +473,10 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self,
err = ixheaacd_calc_frq_bnd_tbls(ptr_header_data[k],
self->pstr_common_tables);
if(err)
{
return err;
}
}
}
@ -479,6 +490,8 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self,
&(pstr_sbr_channel[lr]->str_sbr_dec), ptr_header_data[k],
low_pow_flag, self->pstr_common_tables,
ptr_frame_data[k]->pitch_in_bins, audio_object_type);
if(err < 0)
return err;
}
}
ptr_header_data[k]->status = 0;
@ -518,6 +531,8 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self,
frame_status = ixheaacd_sbr_read_pvc_sce(
ptr_frame_data[k], it_bit_buff, 0, self->ptr_pvc_data_str,
self->pstr_sbr_tables, ptr_header_data[k]);
if(frame_status < 0)
return frame_status;
}
}
if (audio_object_type != AOT_ER_AAC_ELD) {
@ -680,10 +695,12 @@ WORD16 ixheaacd_applysbr(ia_handle_sbr_dec_inst_struct self,
pstr_sbr_channel[1]->str_sbr_dec.time_sample_buf = self->time_sample_buf[1];
if (ele_channels == 1 && usac_flag) {
ixheaacd_esbr_dec(&pstr_sbr_channel[1]->str_sbr_dec, ptr_header_data[1],
WORD32 err_code = ixheaacd_esbr_dec(&pstr_sbr_channel[1]->str_sbr_dec, ptr_header_data[1],
ptr_frame_data[1],
(ptr_header_data[1]->sync_state == SBR_ACTIVE),
low_pow_flag, self->pstr_sbr_tables, ch_fac);
if(err_code)
return err_code;
} else {
if (pstr_drc_dec == NULL) {
WORD32 err_code = ixheaacd_sbr_dec(

View file

@ -20,14 +20,14 @@
#ifndef IXHEAACD_SBRQMFTRANS_H
#define IXHEAACD_SBRQMFTRANS_H
VOID ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer,
WORD32 ixheaacd_qmf_hbe_apply(ia_esbr_hbe_txposer_struct *h_hbe_txposer,
FLOAT32 qmf_buf_real[][64],
FLOAT32 qmf_buf_imag[][64], WORD32 num_columns,
FLOAT32 pv_qmf_buf_real[][64],
FLOAT32 pv_qmf_buf_imag[][64],
WORD32 pitch_in_bins);
VOID ixheaacd_qmf_hbe_data_reinit(
WORD32 ixheaacd_qmf_hbe_data_reinit(
ia_esbr_hbe_txposer_struct *ptr_hbe_transposer_str,
WORD16 *ptr_freq_band_tbl[MAX_FREQ_COEFFS + 1], WORD16 *ptr_num_sf_bands,
WORD32 upsamp_4_flag);

View file

@ -393,6 +393,11 @@ WORD32 ixheaacd_fd_channel_stream(
ixheaacd_scale_factor_data(info, tot_sfb, *max_sfb, info->sfb_per_sbk,
ptr_code_book);
if((it_bit_buff->ptr_read_next > it_bit_buff->ptr_bit_buf_end - 3) && (it_bit_buff->size == it_bit_buff->max_size))
{
return -1;
}
ixheaacd_section_data(usac_data, it_bit_buff, info, global_gain,
usac_data->factors[chn], usac_data->group_dis[chn],
ptr_code_book);

View file

@ -18,9 +18,9 @@
* Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
*/
#ifdef _ARM_
#define xHE_AAC_DEC_ITTIAM_VER "_ARM $Rev: 1.38 $"
#define xHE_AAC_DEC_ITTIAM_VER "_ARM $Rev: 1.41 $"
#elif _X86_
#define xHE_AAC_DEC_ITTIAM_VER "_X86 $Rev: 1.38 $"
#define xHE_AAC_DEC_ITTIAM_VER "_X86 $Rev: 1.41 $"
#else
#define xHE_AAC_DEC_ITTIAM_VER "_MSVC $Rev: 1.38 $"
#define xHE_AAC_DEC_ITTIAM_VER "_MSVC $Rev: 1.41 $"
#endif