diff options
author | Xin Li <delphij@google.com> | 2020-09-01 20:03:58 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-09-01 20:03:58 +0000 |
commit | 386b47b4b1c2247a03c8ff2bf0ed5d5a59b55cb0 (patch) | |
tree | 53061986cbd3d9f031b31dc97935dd9fe1ae5e90 /decoder | |
parent | 924a4628e020fe6553ce2a041cde5a7a1e7ebf69 (diff) | |
parent | 0312fc42cbd168783641a3605e6da363d2062a2f (diff) | |
download | libxaac-temp_sam_168057903.tar.gz |
Merge "Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)" into stage-aosp-mastertemp_sam_168057903
Diffstat (limited to 'decoder')
150 files changed, 2672 insertions, 5476 deletions
diff --git a/decoder/armv7/ixheaacd_fft_armv7.c b/decoder/armv7/ixheaacd_fft_armv7.c index f4ee8de..cf6e1b5 100644 --- a/decoder/armv7/ixheaacd_fft_armv7.c +++ b/decoder/armv7/ixheaacd_fft_armv7.c @@ -1,10 +1,10 @@ #include <stdlib.h> #include <stdio.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_interface.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> +#include "ixheaacd_basic_ops32.h" #include "ixheaacd_function_selector.h" extern const WORD32 ixheaacd_twiddle_table_fft_32x32[514]; diff --git a/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c b/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c index e950ea1..75ca6b3 100644 --- a/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c +++ b/decoder/armv7/ixheaacd_function_selector_arm_non_neon.c @@ -20,15 +20,15 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_sbrdecsettings.h" @@ -37,7 +37,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_pulsedata.h" @@ -50,7 +50,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_block.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" diff --git a/decoder/armv7/ixheaacd_function_selector_armv7.c b/decoder/armv7/ixheaacd_function_selector_armv7.c index cde6269..c9f41f9 100644 --- a/decoder/armv7/ixheaacd_function_selector_armv7.c +++ b/decoder/armv7/ixheaacd_function_selector_armv7.c @@ -20,15 +20,15 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_sbrdecsettings.h" @@ -37,7 +37,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_pulsedata.h" @@ -53,7 +53,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_block.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -199,11 +199,11 @@ VOID(*ixheaacd_mps_complex_fft_64) WORD32 nlength) = &ixheaacd_mps_complex_fft_64_armv7; VOID(*ixheaacd_mps_synt_pre_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_armv7; VOID(*ixheaacd_mps_synt_post_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_armv7; VOID(*ixheaacd_calc_pre_twid) @@ -215,8 +215,9 @@ VOID(*ixheaacd_calc_post_twid) const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_armv7; VOID(*ixheaacd_mps_synt_post_fft_twiddle) -(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_armv7; +(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_armv7; VOID(*ixheaacd_mps_synt_out_calc) (WORD32 resolution, WORD32 *out, WORD32 *state, diff --git a/decoder/armv7/ixheaacd_qmf_dec_armv7.c b/decoder/armv7/ixheaacd_qmf_dec_armv7.c index d02d874..e87ab36 100644 --- a/decoder/armv7/ixheaacd_qmf_dec_armv7.c +++ b/decoder/armv7/ixheaacd_qmf_dec_armv7.c @@ -20,7 +20,7 @@ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_basic_ops32.h" @@ -41,7 +41,7 @@ #include "ixheaacd_env_extr.h" #include "ixheaacd_qmf_dec.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_env_calc.h" #include "ixheaacd_interface.h" diff --git a/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s b/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s index 01736b1..78686c3 100644 --- a/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s +++ b/decoder/armv7/ixheaacd_sbr_qmfanal32_winadds_eld.s @@ -6,9 +6,10 @@ ixheaacd_sbr_qmfanal32_winadds_eld: STMFD sp!, {R4-R12, R14} - LDR R5, [SP, #44] @filterStates - LDR R6, [SP, #48] @timeIn - LDR R7, [SP, #52] @stride + VPUSH {D8 - D15} + LDR R5, [SP, #108] @filterStates + LDR R6, [SP, #112] @timeIn + LDR R7, [SP, #116] @stride MOV R9, R7, LSL #1 @@ -43,7 +44,7 @@ LOOP: BPL LOOP - LDR R4, [SP, #40] @winAdd + LDR R4, [SP, #104] @winAdd MOV R5, #8 VLD1.16 D0, [R0]! @tmpQ1[n + 0] load and incremented R0 by 8 @@ -242,5 +243,5 @@ LOOP_1: VMLAL.S16 Q15, D18, D19 VST1.32 {Q15}, [R11]! - + VPOP {D8 - D15} LDMFD sp!, {R4-R12, R15} diff --git a/decoder/armv8/ixheaacd_function_selector_armv8.c b/decoder/armv8/ixheaacd_function_selector_armv8.c index bf28a30..351e472 100644 --- a/decoder/armv8/ixheaacd_function_selector_armv8.c +++ b/decoder/armv8/ixheaacd_function_selector_armv8.c @@ -20,15 +20,15 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_sbrdecsettings.h" @@ -37,7 +37,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_pulsedata.h" @@ -53,7 +53,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_block.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -198,11 +198,11 @@ VOID(*ixheaacd_mps_complex_fft_64) WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec; VOID(*ixheaacd_mps_synt_pre_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec; VOID(*ixheaacd_mps_synt_post_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec; VOID(*ixheaacd_calc_pre_twid) @@ -214,8 +214,9 @@ VOID(*ixheaacd_calc_post_twid) const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec; VOID(*ixheaacd_mps_synt_post_fft_twiddle) -(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; +(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; VOID(*ixheaacd_mps_synt_out_calc) (WORD32 resolution, WORD32 *out, WORD32 *state, diff --git a/decoder/armv8/ixheaacd_qmf_dec_armv8.c b/decoder/armv8/ixheaacd_qmf_dec_armv8.c index 112f138..2ba9e9f 100644 --- a/decoder/armv8/ixheaacd_qmf_dec_armv8.c +++ b/decoder/armv8/ixheaacd_qmf_dec_armv8.c @@ -19,7 +19,7 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_basic_ops32.h" @@ -40,7 +40,7 @@ #include "ixheaacd_env_extr.h" #include "ixheaacd_qmf_dec.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_env_calc.h" #include "ixheaacd_interface.h" @@ -88,22 +88,22 @@ VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, for (n = 1; n < DCT3_LEN / 2; n++) { temp1[0] = *ptr_forward++; temp1[1] = *ptr_reverse--; - temp1[0] = ixheaacd_add32(ixheaacd_shr32(temp1[0], LP_SHIFT_VAL), - ixheaacd_shr32(temp1[1], LP_SHIFT_VAL)); + temp1[0] = ixheaacd_add32_sat(ixheaacd_shr32(temp1[0], LP_SHIFT_VAL), + ixheaacd_shr32(temp1[1], LP_SHIFT_VAL)); temp1[2] = *(ptr_forward - 33); temp1[3] = *(ptr_reverse - 31); - temp1[1] = ixheaacd_sub32(ixheaacd_shr32(temp1[2], LP_SHIFT_VAL), - ixheaacd_shr32(temp1[3], LP_SHIFT_VAL)); + temp1[1] = ixheaacd_sub32_sat(ixheaacd_shr32(temp1[2], LP_SHIFT_VAL), + ixheaacd_shr32(temp1[3], LP_SHIFT_VAL)); twid_re = *twidle_fwd++; twid_im = *twidle_fwd; twidle_fwd += 3; - *p_out++ = ixheaacd_mult32x16in32(temp1[0], twid_re) + - ixheaacd_mult32x16in32(temp1[1], twid_im); - *p_out++ = -ixheaacd_mult32x16in32(temp1[1], twid_re) + - ixheaacd_mult32x16in32(temp1[0], twid_im); + *p_out++ = ixheaacd_add32_sat(ixheaacd_mult32x16in32(temp1[0], twid_re), + ixheaacd_mult32x16in32(temp1[1], twid_im)); + *p_out++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(temp1[0], twid_im), + ixheaacd_mult32x16in32(temp1[1], twid_re)); } twid_re = *twidle_fwd++; @@ -113,15 +113,15 @@ VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, temp1[1] = *ptr_reverse--; temp1[0] = *(ptr_reverse - 31); - temp1[1] = ixheaacd_sub32(ixheaacd_shr32(temp1[1], LP_SHIFT_VAL), - ixheaacd_shr32(temp1[0], LP_SHIFT_VAL)); + temp1[1] = ixheaacd_sub32_sat(ixheaacd_shr32(temp1[1], LP_SHIFT_VAL), + ixheaacd_shr32(temp1[0], LP_SHIFT_VAL)); temp1[0] = temp1[1]; - temp2[2] = ixheaacd_mult32x16in32(temp1[0], twid_re) + - ixheaacd_mult32x16in32(temp1[1], twid_im); - temp2[3] = -ixheaacd_mult32x16in32(temp1[1], twid_re) + - ixheaacd_mult32x16in32(temp1[0], twid_im); + temp2[2] = ixheaacd_add32_sat(ixheaacd_mult32x16in32(temp1[0], twid_re), + ixheaacd_mult32x16in32(temp1[1], twid_im)); + temp2[3] = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(temp1[0], twid_im), + ixheaacd_mult32x16in32(temp1[1], twid_re)); ptr_forward = output; ptr_reverse = &output[DCT3_LEN - 1]; @@ -129,10 +129,12 @@ VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, temp2[0] = *ptr_forward++; temp2[1] = *ptr_forward--; - temp1[0] = -temp2[1] - temp2[3]; - temp1[1] = temp2[0] - temp2[2]; - temp2[0] = (temp2[0] + temp2[2] + temp1[0]); - temp2[1] = (temp2[1] - temp2[3] + temp1[1]); + temp1[0] = ixheaacd_negate32_sat(ixheaacd_add32_sat(temp2[1], temp2[3])); + temp1[1] = ixheaacd_sub32_sat(temp2[0], temp2[2]); + temp2[0] = + ixheaacd_add32_sat(ixheaacd_add32_sat(temp2[0], temp2[2]), temp1[0]); + temp2[1] = + ixheaacd_add32_sat(ixheaacd_sub32_sat(temp2[1], temp2[3]), temp1[1]); temp2[0] >>= 1; temp2[1] >>= 1; @@ -154,25 +156,25 @@ VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, twid_im = *twidle_fwd; twidle_fwd += 2; - temp1[0] = temp2[0] - temp2[2]; - temp1[1] = (temp2[0] + temp2[2]); + temp1[0] = ixheaacd_sub32_sat(temp2[0], temp2[2]); + temp1[1] = ixheaacd_add32_sat(temp2[0], temp2[2]); - temp1[2] = temp2[1] + temp2[3]; - temp1[3] = (temp2[1] - temp2[3]); + temp1[2] = ixheaacd_add32_sat(temp2[1], temp2[3]); + temp1[3] = ixheaacd_sub32_sat(temp2[1], temp2[3]); - temp1[4] = ixheaacd_mult32x16in32(temp1[0], twid_re) + - ixheaacd_mult32x16in32(temp1[2], twid_im); - temp1[5] = -ixheaacd_mult32x16in32(temp1[2], twid_re) + - ixheaacd_mult32x16in32(temp1[0], twid_im); + temp1[4] = ixheaacd_add32_sat(ixheaacd_mult32x16in32(temp1[0], twid_re), + ixheaacd_mult32x16in32(temp1[2], twid_im)); + temp1[5] = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(temp1[0], twid_im), + ixheaacd_mult32x16in32(temp1[2], twid_re)); temp1[1] >>= 1; temp1[3] >>= 1; - *ptr_forward++ = temp1[1] - temp1[4]; - *ptr_forward++ = temp1[3] + temp1[5]; + *ptr_forward++ = ixheaacd_sub32_sat(temp1[1], temp1[4]); + *ptr_forward++ = ixheaacd_add32_sat(temp1[3], temp1[5]); - *ptr_reverse-- = -temp1[3] + temp1[5]; - *ptr_reverse-- = temp1[1] + temp1[4]; + *ptr_reverse-- = ixheaacd_sub32_sat(temp1[5], temp1[3]); + *ptr_reverse-- = ixheaacd_add32_sat(temp1[1], temp1[4]); } temp2[0] = *ptr_forward++; temp2[1] = *ptr_forward--; @@ -184,21 +186,21 @@ VOID ixheaacd_dct3_32(WORD32 *input, WORD32 *output, twid_im = *twidle_fwd; twidle_fwd += 2; - temp1[0] = temp2[0] - temp2[2]; - temp1[1] = (temp2[0] + temp2[2]); + temp1[0] = ixheaacd_sub32_sat(temp2[0], temp2[2]); + temp1[1] = ixheaacd_add32_sat(temp2[0], temp2[2]); - temp1[2] = temp2[1] + temp2[3]; - temp1[3] = (temp2[1] - temp2[3]); + temp1[2] = ixheaacd_add32_sat(temp2[1], temp2[3]); + temp1[3] = ixheaacd_sub32_sat(temp2[1], temp2[3]); - temp1[4] = ixheaacd_mult32x16in32(temp1[0], twid_re) - - ixheaacd_mult32x16in32(temp1[2], twid_im); - temp1[5] = ixheaacd_mult32x16in32(temp1[2], twid_re) + - ixheaacd_mult32x16in32(temp1[0], twid_im); + temp1[4] = ixheaacd_sub32_sat(ixheaacd_mult32x16in32(temp1[0], twid_re), + ixheaacd_mult32x16in32(temp1[2], twid_im)); + temp1[5] = ixheaacd_add32_sat(ixheaacd_mult32x16in32(temp1[2], twid_re), + ixheaacd_mult32x16in32(temp1[0], twid_im)); temp1[1] >>= 1; temp1[3] >>= 1; - *ptr_forward++ = temp1[1] + temp1[4]; - *ptr_forward++ = temp1[3] + temp1[5]; + *ptr_forward++ = ixheaacd_add32_sat(temp1[1], temp1[4]); + *ptr_forward++ = ixheaacd_add32_sat(temp1[3], temp1[5]); ixheaacd_radix4bfly(w_16, output, 1, 4); ixheaacd_postradixcompute4(input, output, p_table, 16); @@ -314,7 +316,7 @@ VOID ixheaacd_fwd_modulation(const WORD32 *p_time_in1, WORD32 *real_subband, *t_real_subband++ = ixheaacd_sub32_sat(temp1, temp2); ; - *t_imag_subband++ = ixheaacd_add32(temp1, temp2); + *t_imag_subband++ = ixheaacd_add32_sat(temp1, temp2); ; } @@ -332,8 +334,8 @@ VOID ixheaacd_fwd_modulation(const WORD32 *p_time_in1, WORD32 *real_subband, im = *imag_subband; cosh = *tcos++; sinh = *tcos++; - *real_subband++ = ixheaacd_add32(ixheaacd_mult32x16in32_shl(re, cosh), - ixheaacd_mult32x16in32_shl(im, sinh)); + *real_subband++ = ixheaacd_add32_sat(ixheaacd_mult32x16in32_shl(re, cosh), + ixheaacd_mult32x16in32_shl(im, sinh)); *imag_subband++ = ixheaacd_sub32_sat(ixheaacd_mult32x16in32_shl(im, cosh), ixheaacd_mult32x16in32_shl(re, sinh)); } @@ -582,27 +584,27 @@ VOID ixheaacd_esbr_radix4bfly(const WORD32 *w, WORD32 *x, WORD32 index1, mul_11 = ixheaacd_mult64(xt2_0, co30); mul_3 = ixheaacd_mult64(yt2_0, si30); - x[l2] = (WORD32)((mul_3 + mul_11) >> 32) << RADIXSHIFT; + x[l2] = ixheaacd_sat64_32(((mul_3 + mul_11) >> 32) << RADIXSHIFT); mul_5 = ixheaacd_mult64(xt2_0, si30); mul_9 = ixheaacd_mult64(yt2_0, co30); - x[l2 + 1] = (WORD32)((mul_9 - mul_5) >> 32) << RADIXSHIFT; + x[l2 + 1] = ixheaacd_sat64_32(((mul_9 - mul_5) >> 32) << RADIXSHIFT); mul_12 = ixheaacd_mult64(xt0_0, co20); mul_2 = ixheaacd_mult64(yt0_0, si20); - x[l1] = (WORD32)((mul_2 + mul_12) >> 32) << RADIXSHIFT; + x[l1] = ixheaacd_sat64_32(((mul_2 + mul_12) >> 32) << RADIXSHIFT); mul_6 = ixheaacd_mult64(xt0_0, si20); mul_8 = ixheaacd_mult64(yt0_0, co20); - x[l1 + 1] = (WORD32)((mul_8 - mul_6) >> 32) << RADIXSHIFT; + x[l1 + 1] = ixheaacd_sat64_32(((mul_8 - mul_6) >> 32) << RADIXSHIFT); mul_4 = ixheaacd_mult64(xt1_0, co10); mul_1 = ixheaacd_mult64(yt1_0, si10); - x[h2] = (WORD32)((mul_1 + mul_4) >> 32) << RADIXSHIFT; + x[h2] = ixheaacd_sat64_32(((mul_1 + mul_4) >> 32) << RADIXSHIFT); mul_10 = ixheaacd_mult64(xt1_0, si10); mul_7 = ixheaacd_mult64(yt1_0, co10); - x[h2 + 1] = (WORD32)((mul_7 - mul_10) >> 32) << RADIXSHIFT; + x[h2 + 1] = ixheaacd_sat64_32(((mul_7 - mul_10) >> 32) << RADIXSHIFT); x += 2; } @@ -718,23 +720,23 @@ VOID ixheaacd_esbr_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x, x_6 = *x0++; x_7 = *x0++; - xh0_0 = x_0 + x_4; - xh1_0 = x_1 + x_5; - xl0_0 = x_0 - x_4; - xl1_0 = x_1 - x_5; - xh0_1 = x_2 + x_6; - xh1_1 = x_3 + x_7; - xl0_1 = x_2 - x_6; - xl1_1 = x_3 - x_7; - - n00 = xh0_0 + xh0_1; - n01 = xh1_0 + xh1_1; - n10 = xl0_0 + xl1_1; - n11 = xl1_0 - xl0_1; - n20 = xh0_0 - xh0_1; - n21 = xh1_0 - xh1_1; - n30 = xl0_0 - xl1_1; - n31 = xl1_0 + xl0_1; + xh0_0 = ixheaacd_add32_sat(x_0, x_4); + xh1_0 = ixheaacd_add32_sat(x_1, x_5); + xl0_0 = ixheaacd_sub32_sat(x_0, x_4); + xl1_0 = ixheaacd_sub32_sat(x_1, x_5); + xh0_1 = ixheaacd_add32_sat(x_2, x_6); + xh1_1 = ixheaacd_add32_sat(x_3, x_7); + xl0_1 = ixheaacd_sub32_sat(x_2, x_6); + xl1_1 = ixheaacd_sub32_sat(x_3, x_7); + + n00 = ixheaacd_add32_sat(xh0_0, xh0_1); + n01 = ixheaacd_add32_sat(xh1_0, xh1_1); + n10 = ixheaacd_add32_sat(xl0_0, xl1_1); + n11 = ixheaacd_sub32_sat(xl1_0, xl0_1); + n20 = ixheaacd_sub32_sat(xh0_0, xh0_1); + n21 = ixheaacd_sub32_sat(xh1_0, xh1_1); + n30 = ixheaacd_sub32_sat(xl0_0, xl1_1); + n31 = ixheaacd_add32_sat(xl1_0, xl0_1); y0[h2] = n00; y0[h2 + 1] = n01; @@ -754,23 +756,23 @@ VOID ixheaacd_esbr_postradixcompute4(WORD32 *ptr_y, WORD32 *ptr_x, x_e = *x2++; x_f = *x2++; - xh0_2 = x_8 + x_c; - xh1_2 = x_9 + x_d; - xl0_2 = x_8 - x_c; - xl1_2 = x_9 - x_d; - xh0_3 = x_a + x_e; - xh1_3 = x_b + x_f; - xl0_3 = x_a - x_e; - xl1_3 = x_b - x_f; - - n02 = xh0_2 + xh0_3; - n03 = xh1_2 + xh1_3; - n12 = xl0_2 + xl1_3; - n13 = xl1_2 - xl0_3; - n22 = xh0_2 - xh0_3; - n23 = xh1_2 - xh1_3; - n32 = xl0_2 - xl1_3; - n33 = xl1_2 + xl0_3; + xh0_2 = ixheaacd_add32_sat(x_8, x_c); + xh1_2 = ixheaacd_add32_sat(x_9, x_d); + xl0_2 = ixheaacd_sub32_sat(x_8, x_c); + xl1_2 = ixheaacd_sub32_sat(x_9, x_d); + xh0_3 = ixheaacd_add32_sat(x_a, x_e); + xh1_3 = ixheaacd_add32_sat(x_b, x_f); + xl0_3 = ixheaacd_sub32_sat(x_a, x_e); + xl1_3 = ixheaacd_sub32_sat(x_b, x_f); + + n02 = ixheaacd_add32_sat(xh0_2, xh0_3); + n03 = ixheaacd_add32_sat(xh1_2, xh1_3); + n12 = ixheaacd_add32_sat(xl0_2, xl1_3); + n13 = ixheaacd_sub32_sat(xl1_2, xl0_3); + n22 = ixheaacd_sub32_sat(xh0_2, xh0_3); + n23 = ixheaacd_sub32_sat(xh1_2, xh1_3); + n32 = ixheaacd_sub32_sat(xl0_2, xl1_3); + n33 = ixheaacd_add32_sat(xl1_2, xl0_3); y0[h2 + 2] = n02; y0[h2 + 3] = n03; @@ -978,8 +980,8 @@ VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband, (*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; + subband[2 * z] = ixheaacd_shl32_sat(temp[z], scaleshift); + subband[2 * z + 1] = ixheaacd_shl32_sat(temp[z + 8], scaleshift); } scaleshift = 0; for (z = 0; z < (qmf_bank->no_channels >> 1); z++) { @@ -990,8 +992,8 @@ VOID ixheaacd_esbr_cos_sin_mod(WORD32 *subband, (*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; + subband[64 + 2 * z] = ixheaacd_shl32_sat(temp[z], scaleshift); + subband[64 + 2 * z + 1] = ixheaacd_shl32_sat(temp[8 + z], scaleshift); } } @@ -1113,7 +1115,7 @@ VOID ixheaacd_esbr_fwd_modulation( *t_real_subband++ = ixheaacd_sub32_sat(temp1, temp2); ; - *t_imag_subband++ = ixheaacd_add32(temp1, temp2); + *t_imag_subband++ = ixheaacd_add32_sat(temp1, temp2); ; } @@ -1131,13 +1133,14 @@ VOID ixheaacd_esbr_fwd_modulation( im = *imag_subband; cosh = *tcos++; sinh = *tcos++; - *real_subband++ = (WORD32)((ixheaacd_add64(ixheaacd_mult64(re, cosh), - ixheaacd_mult64(im, sinh))) >> - 31); + *real_subband++ = + ixheaacd_sat64_32((ixheaacd_add64(ixheaacd_mult64(re, cosh), + ixheaacd_mult64(im, sinh))) >> + 31); *imag_subband++ = - (WORD32)((ixheaacd_sub64_sat(ixheaacd_mult64(im, cosh), - ixheaacd_mult64(re, sinh))) >> - 31); + ixheaacd_sat64_32((ixheaacd_sub64_sat(ixheaacd_mult64(im, cosh), + ixheaacd_mult64(re, sinh))) >> + 31); } } @@ -1170,7 +1173,7 @@ VOID ixheaacd_esbr_qmfsyn64_winadd(WORD32 *tmp1, WORD32 *tmp2, WORD32 *inp1, syn_out = ixheaacd_add64(syn_out, ixheaacd_mult64(tmp2[1152 + k], inp1[k + 576])); - sample_buffer[ch_fac * k] = (WORD32)(syn_out >> 31); + sample_buffer[ch_fac * k] = ixheaacd_sat64_32(syn_out >> 31); } } @@ -1276,58 +1279,58 @@ VOID ixheaacd_radix4bfly(const WORD16 *w, WORD32 *x, WORD32 index1, x_l1_0 = x[l1]; x_l2_0 = x[l2]; - xh0_0 = x_0 + x_l1_0; - xl0_0 = x_0 - x_l1_0; + xh0_0 = ixheaacd_add32_sat(x_0, x_l1_0); + xl0_0 = ixheaacd_sub32_sat(x_0, x_l1_0); - xh20_0 = x_h2_0 + x_l2_0; - xl20_0 = x_h2_0 - x_l2_0; + xh20_0 = ixheaacd_add32_sat(x_h2_0, x_l2_0); + xl20_0 = ixheaacd_sub32_sat(x_h2_0, x_l2_0); - x[0] = xh0_0 + xh20_0; - xt0_0 = xh0_0 - xh20_0; + x[0] = ixheaacd_add32_sat(xh0_0, xh20_0); + xt0_0 = ixheaacd_sub32_sat(xh0_0, xh20_0); x_1 = x[1]; x_h2_1 = x[h2 + 1]; x_l1_1 = x[l1 + 1]; x_l2_1 = x[l2 + 1]; - xh1_0 = x_1 + x_l1_1; - xl1_0 = x_1 - x_l1_1; + xh1_0 = ixheaacd_add32_sat(x_1, x_l1_1); + xl1_0 = ixheaacd_sub32_sat(x_1, x_l1_1); - xh21_0 = x_h2_1 + x_l2_1; - xl21_0 = x_h2_1 - x_l2_1; + xh21_0 = ixheaacd_add32_sat(x_h2_1, x_l2_1); + xl21_0 = ixheaacd_sub32_sat(x_h2_1, x_l2_1); - x[1] = xh1_0 + xh21_0; - yt0_0 = xh1_0 - xh21_0; + x[1] = ixheaacd_add32_sat(xh1_0, xh21_0); + yt0_0 = ixheaacd_sub32_sat(xh1_0, xh21_0); - xt1_0 = xl0_0 + xl21_0; - xt2_0 = xl0_0 - xl21_0; + xt1_0 = ixheaacd_add32_sat(xl0_0, xl21_0); + xt2_0 = ixheaacd_sub32_sat(xl0_0, xl21_0); - yt2_0 = xl1_0 + xl20_0; - yt1_0 = xl1_0 - xl20_0; + yt2_0 = ixheaacd_add32_sat(xl1_0, xl20_0); + yt1_0 = ixheaacd_sub32_sat(xl1_0, xl20_0); mul_11 = ixheaacd_mult32x16in32(xt2_0, co30); mul_3 = ixheaacd_mult32x16in32(yt2_0, si30); - x[l2] = (mul_3 + mul_11) << RADIXSHIFT; + x[l2] = ixheaacd_shl32_sat((mul_3 + mul_11), RADIXSHIFT); mul_5 = ixheaacd_mult32x16in32(xt2_0, si30); mul_9 = ixheaacd_mult32x16in32(yt2_0, co30); - x[l2 + 1] = (mul_9 - mul_5) << RADIXSHIFT; + x[l2 + 1] = ixheaacd_shl32_sat((mul_9 - mul_5), RADIXSHIFT); mul_12 = ixheaacd_mult32x16in32(xt0_0, co20); mul_2 = ixheaacd_mult32x16in32(yt0_0, si20); - x[l1] = (mul_2 + mul_12) << RADIXSHIFT; + x[l1] = ixheaacd_shl32_sat((mul_2 + mul_12), RADIXSHIFT); mul_6 = ixheaacd_mult32x16in32(xt0_0, si20); mul_8 = ixheaacd_mult32x16in32(yt0_0, co20); - x[l1 + 1] = (mul_8 - mul_6) << RADIXSHIFT; + x[l1 + 1] = ixheaacd_shl32_sat((mul_8 - mul_6), RADIXSHIFT); mul_4 = ixheaacd_mult32x16in32(xt1_0, co10); mul_1 = ixheaacd_mult32x16in32(yt1_0, si10); - x[h2] = (mul_1 + mul_4) << RADIXSHIFT; + x[h2] = ixheaacd_shl32_sat((mul_1 + mul_4), RADIXSHIFT); mul_10 = ixheaacd_mult32x16in32(xt1_0, si10); mul_7 = ixheaacd_mult32x16in32(yt1_0, co10); - x[h2 + 1] = (mul_7 - mul_10) << RADIXSHIFT; + x[h2 + 1] = ixheaacd_shl32_sat((mul_7 - mul_10), RADIXSHIFT); x += 2; } diff --git a/decoder/drc_src/impd_drc_api.c b/decoder/drc_src/impd_drc_api.c index 4fea3de..f7443e1 100644 --- a/decoder/drc_src/impd_drc_api.c +++ b/decoder/drc_src/impd_drc_api.c @@ -56,8 +56,6 @@ IA_ERRORCODE impd_drc_mem_api(ia_drc_api_struct *p_obj_drc, WORD32 i_cmd, IA_ERRORCODE impd_drc_fill_mem_tables(ia_drc_api_struct *p_obj_drc); -VOID impd_drc_set_default_config_params(ia_drc_config_struct *ptr_config); - IA_ERRORCODE impd_drc_process_frame(ia_drc_api_struct *p_obj_drc); IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc); IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc); @@ -83,10 +81,10 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc); 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_BS_BUF_SIZE + /*DRC Config Bitstream*/ \ - MAX_DRC_CONFG_BUF_SIZE + /*DRC loudness info Bitstream*/ \ - MAX_LOUD_INFO_BUF_SIZE + /*DRC interface Bitstream*/ \ - MAX_INTERFACE_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*/ \ @@ -151,7 +149,7 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, case IA_API_CMD_INIT: { switch (i_idx) { case IA_CMD_TYPE_INIT_SET_BUFF_PTR: { - p_obj_drc->p_state->persistant_ptr = + p_obj_drc->p_state->persistent_ptr = (UWORD8 *)p_obj_drc->pp_mem[IA_DRC_PERSIST_IDX] + sizeof(ia_drc_state_struct); impd_drc_set_struct_pointer(p_obj_drc); @@ -207,11 +205,16 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, } case IA_CMD_TYPE_INIT_CPY_BSF_BUFF: { memcpy(p_obj_drc->str_bit_handler.it_bit_buf + - p_obj_drc->str_bit_handler.num_bytes_bs, + p_obj_drc->str_bit_handler.num_bytes_offset_bs, p_obj_drc->pp_mem[2], p_obj_drc->str_bit_handler.num_byts_cur); p_obj_drc->str_bit_handler.num_bytes_bs = p_obj_drc->str_bit_handler.num_bytes_bs + p_obj_drc->str_bit_handler.num_byts_cur; + p_obj_drc->str_bit_handler.num_bytes_offset_bs = + p_obj_drc->str_bit_handler.num_bytes_bs; + p_obj_drc->str_bit_handler.num_total_bytes = + p_obj_drc->str_bit_handler.num_bytes_bs; + break; } case IA_CMD_TYPE_INIT_CPY_IC_BSF_BUFF: { @@ -268,60 +271,6 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, } case IA_API_CMD_SET_CONFIG_PARAM: { switch (i_idx) { - case IA_DRC_DEC_CONFIG_PARAM_DEC_TYPE: { - if (*pus_value == 1) { - p_obj_drc->str_config.dec_type = DEC_TYPE_TD_QMF64; - p_obj_drc->str_config.sub_band_domain_mode = - SUBBAND_DOMAIN_MODE_QMF64; - p_obj_drc->str_config.sub_band_down_sampling_factor = - AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; - p_obj_drc->str_config.sub_band_count = - AUDIO_CODEC_SUBBAND_COUNT_QMF64; - } else if (*pus_value == 2) { - p_obj_drc->str_config.dec_type = DEC_TYPE_QMF64; - p_obj_drc->str_config.sub_band_domain_mode = - SUBBAND_DOMAIN_MODE_QMF64; - p_obj_drc->str_config.sub_band_down_sampling_factor = - AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; - p_obj_drc->str_config.sub_band_count = - AUDIO_CODEC_SUBBAND_COUNT_QMF64; - } else if (*pus_value == 3) { - p_obj_drc->str_config.dec_type = DEC_TYPE_STFT256; - p_obj_drc->str_config.sub_band_domain_mode = - SUBBAND_DOMAIN_MODE_STFT256; - p_obj_drc->str_config.sub_band_down_sampling_factor = - AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; - p_obj_drc->str_config.sub_band_count = - AUDIO_CODEC_SUBBAND_COUNT_STFT256; - } else { - p_obj_drc->str_config.dec_type = DEC_TYPE_TD; - p_obj_drc->str_config.sub_band_domain_mode = - SUBBAND_DOMAIN_MODE_OFF; - } - - if (*pus_value < 0 || *pus_value > 3) { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DECODE_TYPE; - } - break; - } - case IA_DRC_DEC_CONFIG_PARAM_CTRL_PARAM: { - if (*pus_value < 1 || *pus_value > 39) { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_CTRL_PARAM_IDX; - } - p_obj_drc->str_config.control_parameter_index = *pus_value; - break; - } - case IA_DRC_DEC_CONFIG_PARAM_PEAK_LIMITER: { - if (*pus_value < 0 || *pus_value > 1) { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PEAK_LIM_FLAG; - } - p_obj_drc->str_config.peak_limiter = *pus_value; - break; - } - - case IA_DRC_DEC_CONFIG_PARAM_VER_MODE: { - break; - } case IA_DRC_DEC_CONFIG_PARAM_SAMP_FREQ: { if (*pus_value < 8000 || *pus_value > 96000) { return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_SAMP_FREQ; @@ -338,8 +287,13 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, } case IA_DRC_DEC_CONFIG_PARAM_PCM_WDSZ: { - if ((*pus_value != 16) && (*pus_value != 32)) { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PCM_SIZE; + switch (*pus_value) { + case 16: + case 24: + case 32: + break; + default: + return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_PCM_SIZE; } p_obj_drc->str_config.pcm_size = *pus_value; @@ -348,54 +302,9 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, } case IA_DRC_DEC_CONFIG_PARAM_BITS_FORMAT: { - if ((*pus_value != 1) && (*pus_value != 0)) { - return -1; - } - p_obj_drc->str_config.bitstream_file_format = *pus_value; - break; } case IA_DRC_DEC_CONFIG_PARAM_INT_PRESENT: { - if ((*pus_value != 1) && (*pus_value != 0)) { - return -1; - } - p_obj_drc->str_config.interface_bitstream_present = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_DELAY_MODE: { - if ((*pus_value != 1) && (*pus_value != 0)) { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_DELAY_MODE; - } - p_obj_drc->str_config.delay_mode = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_GAIN_DELAY: { - if ((*pus_value > MAX_SIGNAL_DELAY) || (*pus_value < 0)) { - return IA_DRC_DEC_CONFIG_NON_FATAL_INVALID_GAIN_DELAY; - } - - p_obj_drc->str_config.gain_delay_samples = *pus_value; - - break; - } - - /*Sujith: introduce error*/ - case IA_DRC_DEC_CONFIG_PARAM_AUDIO_DELAY: { - break; - } - case IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE: { - if (*pus_value < 0 || *pus_value > 1) { - return IA_DRC_DEC_CONFIG_PARAM_CON_DELAY_MODE; - } - p_obj_drc->str_config.constant_delay_on = *pus_value; - - break; - } - case IA_DRC_DEC_CONFIG_PARAM_ABSO_DELAY_OFF: { - p_obj_drc->str_config.absorb_delay_on = *pus_value; - break; } case IA_DRC_DEC_CONFIG_PARAM_FRAME_SIZE: { @@ -408,7 +317,6 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, break; } case IA_DRC_DEC_CONFIG_GAIN_STREAM_FLAG: { - p_obj_drc->str_bit_handler.gain_stream_flag = *pus_value; break; } @@ -460,12 +368,17 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_TD) { error_code = impd_process_time_domain(p_obj_drc); } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_QMF64) { - error_code = impd_init_process_audio_main_qmf(p_obj_drc); + error_code = IA_FATAL_ERROR; } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_STFT256) { - error_code = impd_init_process_audio_main_stft(p_obj_drc); + error_code = IA_FATAL_ERROR; } else if (p_obj_drc->str_config.dec_type == DEC_TYPE_TD_QMF64) { - error_code = impd_init_process_audio_main_td_qmf(p_obj_drc); + error_code = IA_FATAL_ERROR; } + p_obj_drc->str_bit_handler.byte_index_bs = + p_obj_drc->str_bit_handler.num_total_bytes - + p_obj_drc->str_bit_handler.num_bytes_bs; + p_obj_drc->str_bit_handler.num_bytes_offset_bs = 0; + break; } case IA_CMD_TYPE_DONE_QUERY: { @@ -499,22 +412,6 @@ IA_ERRORCODE ia_drc_dec_api(pVOID p_ia_drc_dec_obj, WORD32 i_cmd, WORD32 i_idx, p_obj_drc->p_state->ui_exe_done = 1; break; } - case IA_API_CMD_INPUT_OVER_BS: { - p_obj_drc->str_bit_handler.cpy_over = 1; - break; - } - case IA_API_CMD_INPUT_OVER_IC_BS: { - p_obj_drc->str_bit_handler.cpy_over_ic = 1; - break; - } - case IA_API_CMD_INPUT_OVER_IL_BS: { - p_obj_drc->str_bit_handler.cpy_over_il = 1; - break; - } - case IA_API_CMD_INPUT_OVER_IN_BS: { - p_obj_drc->str_bit_handler.cpy_over_in = 1; - break; - } case IA_API_CMD_SET_INPUT_BYTES_BS: { p_obj_drc->str_bit_handler.num_byts_cur = *pus_value; break; diff --git a/decoder/drc_src/impd_drc_api_struct_def.h b/decoder/drc_src/impd_drc_api_struct_def.h index a48cd68..6c2734a 100644 --- a/decoder/drc_src/impd_drc_api_struct_def.h +++ b/decoder/drc_src/impd_drc_api_struct_def.h @@ -71,6 +71,8 @@ typedef struct bits_handler { WORD32 num_bits_read_bs; WORD32 num_bytes_read_bs; WORD32 num_bytes_bs; + WORD32 num_bytes_offset_bs; + WORD32 num_total_bytes; WORD32 num_bits_offset_bs; WORD32 byte_index_bs; WORD32 num_byts_cur; @@ -112,7 +114,7 @@ typedef struct ia_drc_state_struct { UWORD32 ui_ir_used; WORD32 delay_in_output; WORD32 delay_adjust_samples; - pVOID persistant_ptr; + pVOID persistent_ptr; } ia_drc_state_struct; typedef struct IA_PSM_API_Struct { diff --git a/decoder/drc_src/impd_drc_bitbuffer.c b/decoder/drc_src/impd_drc_bitbuffer.c index 3750f11..e623bc8 100644 --- a/decoder/drc_src/impd_drc_bitbuffer.c +++ b/decoder/drc_src/impd_drc_bitbuffer.c @@ -121,6 +121,9 @@ WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, ia_drc_params_bs_dec_struct* ia_drc_params_struct = &p_drc_bs_dec_struct->ia_drc_params_struct; ia_drc_params_struct->drc_frame_size = frame_size; + if (sample_rate < MIN_DRC_SAMP_FREQ) { + return -1; + } ia_drc_params_struct->delta_tmin_default = impd_get_delta_tmin(sample_rate); ia_drc_params_struct->num_gain_values_max_default = ia_drc_params_struct->drc_frame_size / @@ -131,9 +134,6 @@ WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, (ia_drc_params_struct->drc_frame_size < 0.001f * sample_rate)) { return -1; } - if (sample_rate < 1000) { - return -1; - } if (ia_drc_params_struct->delta_tmin_default > ia_drc_params_struct->drc_frame_size) { @@ -165,51 +165,6 @@ WORD32 impd_init_drc_bitstream_dec(ia_drc_bits_dec_struct* p_drc_bs_dec_struct, return err_code; } -WORD32 impd_process_drc_bitstream_dec( - ia_drc_bits_dec_struct* p_drc_bs_dec_struct, ia_bit_buf_struct* it_bit_buff, - ia_drc_config* pstr_drc_config, - ia_drc_loudness_info_set_struct* pstr_loudness_info, - UWORD8* bitstream_config, WORD32 num_bytes, WORD32 num_bits_offset, - WORD32* num_bits_read) { - WORD32 err_code = 0; - - WORD32 loudness_info_set_present, drc_config_present, dummy; - - if (bitstream_config == NULL) { - *num_bits_read = 0; - } else { - it_bit_buff = - impd_create_init_bit_buf(it_bit_buff, bitstream_config, num_bytes); - - dummy = impd_read_bits_buf(it_bit_buff, num_bits_offset); - if (it_bit_buff->error) return it_bit_buff->error; - - loudness_info_set_present = impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - - if (loudness_info_set_present) { - drc_config_present = impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - - if (drc_config_present) { - err_code = impd_parse_drc_config( - it_bit_buff, &p_drc_bs_dec_struct->ia_drc_params_struct, - pstr_drc_config); - - if (err_code) return (err_code); - } - - err_code = impd_parse_loudness_info_set(it_bit_buff, pstr_loudness_info); - - if (err_code) return (err_code); - } - - *num_bits_read = it_bit_buff->size - it_bit_buff->cnt_bits; - } - - return err_code; -} - WORD32 impd_process_drc_bitstream_dec_config( ia_drc_bits_dec_struct* p_drc_bs_dec_struct, ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, UWORD8* bitstream_config, diff --git a/decoder/drc_src/impd_drc_bitstream_dec_api.h b/decoder/drc_src/impd_drc_bitstream_dec_api.h index 25773d5..eb1e5ba 100644 --- a/decoder/drc_src/impd_drc_bitstream_dec_api.h +++ b/decoder/drc_src/impd_drc_bitstream_dec_api.h @@ -25,13 +25,6 @@ WORD32 impd_init_drc_bitstream_dec( WORD32 frame_size, WORD32 delay_mode, WORD32 lfe_channel_map_count, WORD32* lfe_channel_map); -WORD32 impd_process_drc_bitstream_dec( - ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, - ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, - ia_drc_loudness_info_set_struct* pstr_loudness_info, - UWORD8* bitstream_config, WORD32 num_bytes, WORD32 num_bits_offset, - WORD32* num_bits_read); - WORD32 impd_process_drc_bitstream_dec_config( ia_drc_bits_dec_struct* p_uni_drc_bs_dec_struct, ia_bit_buf_struct* it_bit_buff, ia_drc_config* pstr_drc_config, diff --git a/decoder/drc_src/impd_drc_common.h b/decoder/drc_src/impd_drc_common.h index 2afe708..3dbbd2c 100644 --- a/decoder/drc_src/impd_drc_common.h +++ b/decoder/drc_src/impd_drc_common.h @@ -53,6 +53,8 @@ extern "C" { #define NUM_ELE_IN_CPLX_NUM 2 #define MAX_BS_BUF_SIZE 768 +#define MAX_NUM_DRC_PAYROLL 3 +#define MAX_DRC_BS_BUF_SIZE (MAX_BS_BUF_SIZE * MAX_NUM_DRC_PAYROLL) #define MAX_DRC_CONFG_BUF_SIZE MAX_BS_BUF_SIZE #define MAX_LOUD_INFO_BUF_SIZE MAX_BS_BUF_SIZE #define MAX_INTERFACE_BUF_SIZE MAX_BS_BUF_SIZE @@ -213,6 +215,8 @@ extern "C" { #define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f +#define MIN_DRC_SAMP_FREQ 1000 + #ifndef min #define min(a, b) ((a) < (b) ? (a) : (b)) #endif diff --git a/decoder/drc_src/impd_drc_dynamic_payload.c b/decoder/drc_src/impd_drc_dynamic_payload.c index dca5466..a8a15a9 100644 --- a/decoder/drc_src/impd_drc_dynamic_payload.c +++ b/decoder/drc_src/impd_drc_dynamic_payload.c @@ -272,8 +272,10 @@ WORD32 impd_dec_times(ia_bit_buf_struct* it_bit_buff, e++; } } - str_node[k].time = time_offs + time_delta * delta_tmin; - time_offs = str_node[k].time; + time_offs += time_delta * delta_tmin; + if (time_offs >= (2 * AUDIO_CODEC_FRAME_SIZE_MAX - drc_frame_size)) + return UNEXPECTED_ERROR; + str_node[k].time = time_offs; } } return (0); @@ -295,9 +297,13 @@ WORD32 impd_drc_uni_gain_read(ia_bit_buf_struct* it_bit_buff, for (seq = 0; seq < gain_sequence_count; seq++) { WORD32 index = drc_config->str_p_loc_drc_coefficients_uni_drc[0] .gain_set_params_index_for_gain_sequence[seq]; - ia_gain_set_params_struct* gain_set_params = - &(drc_config->str_p_loc_drc_coefficients_uni_drc - ->gain_set_params[index]); + ia_gain_set_params_struct str_gain_set_params = {0}; + ia_gain_set_params_struct* gain_set_params = &str_gain_set_params; + + if (index != -1) { + gain_set_params = &(drc_config->str_p_loc_drc_coefficients_uni_drc + ->gain_set_params[index]); + } if (gain_set_params->gain_coding_profile == GAIN_CODING_PROFILE_CONSTANT) { str_spline_nodes = @@ -394,6 +400,9 @@ WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, } if (it_bit_buff->ptr_bit_buf_base == NULL) { + if ((str_spline_nodes->num_nodes < 1) || + (str_spline_nodes->num_nodes > NODE_COUNT_MAX)) + return UNEXPECTED_ERROR; FLOAT32 prev_db_gain = str_spline_nodes->str_node[str_spline_nodes->num_nodes - 1].loc_db_gain; str_spline_nodes->drc_gain_coding_mode = 0; @@ -413,6 +422,9 @@ WORD32 impd_parse_spline_nodes(ia_bit_buf_struct* it_bit_buff, } else { str_spline_nodes->drc_gain_coding_mode = impd_read_bits_buf(it_bit_buff, 1); if (it_bit_buff->error == PROC_COMPLETE) { + if ((str_spline_nodes->num_nodes < 1) || + (str_spline_nodes->num_nodes > NODE_COUNT_MAX)) + return UNEXPECTED_ERROR; str_spline_nodes->drc_gain_coding_mode = 0; str_spline_nodes->str_node[0].slope = 0.0; str_spline_nodes->str_node[0].time = @@ -509,9 +521,12 @@ WORD32 impd_parse_drc_gain_sequence( } } for (k = 0; k < num_nodes_node_reservoir; k++) { - drc_gain_sequence->str_spline_nodes[i].str_node[k].time = - prev_frame_time_buf[k] - - 2 * pstr_drc_uni_bs_dec->ia_drc_params_struct.drc_frame_size; + WORD32 tmp = prev_frame_time_buf[k] - + 2 * pstr_drc_uni_bs_dec->ia_drc_params_struct.drc_frame_size; + if (tmp >= (2 * AUDIO_CODEC_FRAME_SIZE_MAX - + pstr_drc_uni_bs_dec->ia_drc_params_struct.drc_frame_size)) + return UNEXPECTED_ERROR; + drc_gain_sequence->str_spline_nodes[i].str_node[k].time = tmp; } for (m = 0; m < num_nodes_cur; m++, k++) { drc_gain_sequence->str_spline_nodes[i].str_node[k].time = @@ -574,6 +589,11 @@ WORD32 impd_parse_drc_ext_v1(ia_bit_buf_struct* it_bit_buff, drc_instructions_uni_drc_v1_count = impd_read_bits_buf(it_bit_buff, 6); if (it_bit_buff->error) return it_bit_buff->error; + if (drc_config->drc_instructions_uni_drc_count + + drc_instructions_uni_drc_v1_count > + DRC_INSTRUCTIONS_COUNT_MAX) + return (UNEXPECTED_ERROR); + for (i = 0; i < drc_instructions_uni_drc_v1_count; i++) { err = impd_parse_drc_instructions_uni_drc( it_bit_buff, version, drc_config, @@ -591,9 +611,6 @@ WORD32 impd_parse_drc_ext_v1(ia_bit_buf_struct* it_bit_buff, if (str_drc_config_ext->loud_eq_instructions_flag == 1) { str_drc_config_ext->loud_eq_instructions_count = impd_read_bits_buf(it_bit_buff, 4); - if (str_drc_config_ext->loud_eq_instructions_count > - LOUD_EQ_INSTRUCTIONS_COUNT_MAX) - return UNEXPECTED_ERROR; if (it_bit_buff->error) return it_bit_buff->error; if (str_drc_config_ext->loud_eq_instructions_count > @@ -1072,7 +1089,7 @@ WORD32 impd_parser_td_filter_cascade( WORD32 impd_parse_eq_instructions( ia_bit_buf_struct* it_bit_buff, ia_drc_config* drc_config, ia_eq_instructions_struct* str_eq_instructions) { - WORD32 i, k, channel_count, temp; + WORD32 i, channel_count, temp; WORD32 dmix_id_present, additional_dmix_id_present, additional_dmix_id_cnt = 0; WORD32 additional_drc_set_id_present, additional_drc_set_id_cnt; @@ -1182,22 +1199,20 @@ WORD32 impd_parse_eq_instructions( str_eq_instructions->eq_ch_group_count = 0; for (i = 0; i < channel_count; i++) { - WORD32 new_group = 1; - str_eq_instructions->eq_ch_group_of_channel[i] = - impd_read_bits_buf(it_bit_buff, 7); + WORD32 tmp = impd_read_bits_buf(it_bit_buff, 7); if (it_bit_buff->error) return it_bit_buff->error; - - for (k = 0; k < i; k++) { - if (str_eq_instructions->eq_ch_group_of_channel[i] == - str_eq_instructions->eq_ch_group_of_channel[k]) { - new_group = 0; - break; - } - } - - if (new_group == 1) { - str_eq_instructions->eq_ch_group_count += 1; - } + if (tmp >= EQ_CHANNEL_GROUP_COUNT_MAX) return UNEXPECTED_ERROR; + str_eq_instructions->eq_ch_group_of_channel[i] = tmp; + } + { + WORD32 total; + WORD32 groups_used[EQ_CHANNEL_GROUP_COUNT_MAX] = {0}; + for (i = 0; i < channel_count; i++) + groups_used[str_eq_instructions->eq_ch_group_of_channel[i]] = 1; + total = 0; + for (i = 0; i < EQ_CHANNEL_GROUP_COUNT_MAX; i++) + if (groups_used[i]) total++; + str_eq_instructions->eq_ch_group_count = total; } if (str_eq_instructions->eq_ch_group_count > EQ_CHANNEL_GROUP_COUNT_MAX) @@ -1208,9 +1223,10 @@ WORD32 impd_parse_eq_instructions( if (it_bit_buff->error) return it_bit_buff->error; if (str_eq_instructions->td_filter_cascade_present) { - impd_parser_td_filter_cascade( + WORD32 err = impd_parser_td_filter_cascade( it_bit_buff, str_eq_instructions, &(str_eq_instructions->str_td_filter_cascade)); + if (err) return err; } str_eq_instructions->subband_gains_present = @@ -1219,9 +1235,10 @@ WORD32 impd_parse_eq_instructions( if (str_eq_instructions->subband_gains_present) { for (i = 0; i < str_eq_instructions->eq_ch_group_count; i++) { - str_eq_instructions->subband_gains_index[i] = - impd_read_bits_buf(it_bit_buff, 6); + WORD32 tmp = impd_read_bits_buf(it_bit_buff, 6); if (it_bit_buff->error) return it_bit_buff->error; + if (tmp >= UNIQUE_SUBBAND_GAIN_COUNT_MAX) return UNEXPECTED_ERROR; + str_eq_instructions->subband_gains_index[i] = tmp; } } diff --git a/decoder/drc_src/impd_drc_eq.c b/decoder/drc_src/impd_drc_eq.c index c9983db..c72895f 100644 --- a/decoder/drc_src/impd_drc_eq.c +++ b/decoder/drc_src/impd_drc_eq.c @@ -1254,26 +1254,6 @@ VOID impd_pole_zero_filt_process(ia_pole_zero_filt_struct* pstr_pole_zero_filt, return; } -VOID impd_subband_filter_process(ia_subband_filt_struct* pstr_subband_filt, - FLOAT32* ptr_audio_real_buff, - FLOAT32* ptr_audio_imag_buff) { - WORD32 i, j; - WORD32 eq_frame_size_subband = pstr_subband_filt->eq_frame_size_subband; - WORD32 coeff_count = pstr_subband_filt->coeff_count; - - FLOAT32* ptr_subband_coeff = pstr_subband_filt->subband_coeff; - - for (i = 0; i < eq_frame_size_subband; i++) { - for (j = 0; j < coeff_count; j++) { - ptr_audio_real_buff[j] *= ptr_subband_coeff[j]; - ptr_audio_imag_buff[j] *= ptr_subband_coeff[j]; - } - ptr_audio_real_buff += coeff_count; - ptr_audio_imag_buff += coeff_count; - } - return; -} - VOID impd_phase_align_filt_process( ia_ph_alignment_filt_struct* ph_alignment_filt, WORD32 channel, FLOAT32* ptr_audio_out) { @@ -1365,23 +1345,3 @@ WORD32 impd_process_eq_set_time_domain(ia_eq_set_struct* pstr_eq_set, return 0; } -WORD32 impd_process_eq_set_subband_domain(ia_eq_set_struct* pstr_eq_set, - WORD32 channel, - FLOAT32* ptr_audio_real_buff, - FLOAT32* ptr_audio_imag_buff) { - WORD32 g; - - if (pstr_eq_set != NULL) { - g = pstr_eq_set->eq_ch_group_of_channel[channel]; - if (g >= 0) { - if (pstr_eq_set->domain == 0) { - return (-1); - } else { - impd_subband_filter_process(&pstr_eq_set->subband_filt[g], - &ptr_audio_real_buff[0], - &ptr_audio_imag_buff[0]); - } - } - } - return (0); -} diff --git a/decoder/drc_src/impd_drc_eq.h b/decoder/drc_src/impd_drc_eq.h index d45e7ed..70c8050 100644 --- a/decoder/drc_src/impd_drc_eq.h +++ b/decoder/drc_src/impd_drc_eq.h @@ -178,11 +178,6 @@ impd_process_eq_set_td(ia_eq_set_struct* eq_set, WORD32 channel, WORD32 impd_process_eq_set_time_domain(ia_eq_set_struct* eq_set, WORD32 channel, FLOAT32* audio_in, FLOAT32* audio_out, WORD32 frame_size); -WORD32 -impd_process_eq_set_subband_domain(ia_eq_set_struct* eq_set, WORD32 channel, - FLOAT32* subbandSampleIn, - FLOAT32* subbandSampleOut); - #ifdef __cplusplus } #endif diff --git a/decoder/drc_src/impd_drc_extr_delta_coded_info.c b/decoder/drc_src/impd_drc_extr_delta_coded_info.c index a1ca0b7..485e629 100644 --- a/decoder/drc_src/impd_drc_extr_delta_coded_info.c +++ b/decoder/drc_src/impd_drc_extr_delta_coded_info.c @@ -87,9 +87,6 @@ WORD32 impd_get_delta_tmin(const WORD32 sampling_rate) { WORD32 lowerBound = (WORD32)(0.5f + 0.0005f * sampling_rate); WORD32 result = 1; - if (sampling_rate < 1000) { - return (UNEXPECTED_ERROR); - } while (result <= lowerBound) result = result << 1; return result; } diff --git a/decoder/drc_src/impd_drc_fiilter_bank.c b/decoder/drc_src/impd_drc_fiilter_bank.c deleted file mode 100644 index f6637b6..0000000 --- a/decoder/drc_src/impd_drc_fiilter_bank.c +++ /dev/null @@ -1,431 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2015 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 <stdio.h> -#include <stdlib.h> -#include <math.h> - -#include "impd_type_def.h" -#include "impd_drc_uni_tables.h" -#include "impd_drc_uni_common.h" -#include "impd_drc_struct.h" -#include "impd_drc_filter_bank.h" -#include "impd_drc_rom.h" - -VOID impd_compute_filt_coeff(WORD32 crossover_freq_idx, - ia_iir_filter_struct* pstr_lp_filt_coeff, - ia_iir_filter_struct* pstr_hp_filt_coeff, - ia_iir_filter_struct* pstr_ap_filt_coeff, - WORD32 filter_type) { - FLOAT32 gamma = normal_cross_freq[crossover_freq_idx].gamma; - FLOAT32 delta = normal_cross_freq[crossover_freq_idx].delta; - - if (filter_type == 0 || filter_type == 2) { - pstr_lp_filt_coeff->a0 = 1.0f; - pstr_lp_filt_coeff->a1 = 2.0f * (gamma - delta); - pstr_lp_filt_coeff->a2 = 2.0f * (gamma + delta) - 1.0f; - pstr_lp_filt_coeff->b0 = gamma; - pstr_lp_filt_coeff->b1 = 2.0f * gamma; - pstr_lp_filt_coeff->b2 = gamma; - - pstr_hp_filt_coeff->a0 = 1.0f; - pstr_hp_filt_coeff->a1 = pstr_lp_filt_coeff->a1; - pstr_hp_filt_coeff->a2 = pstr_lp_filt_coeff->a2; - pstr_hp_filt_coeff->b0 = delta; - pstr_hp_filt_coeff->b1 = -2.0f * delta; - pstr_hp_filt_coeff->b2 = delta; - } - - if (filter_type == 1 || filter_type == 2) { - pstr_ap_filt_coeff->a0 = 1.0f; - pstr_ap_filt_coeff->a1 = 2.0f * (gamma - delta); - ; - pstr_ap_filt_coeff->a2 = 2.0f * (gamma + delta) - 1.0f; - ; - pstr_ap_filt_coeff->b0 = pstr_ap_filt_coeff->a2; - pstr_ap_filt_coeff->b1 = pstr_ap_filt_coeff->a1; - pstr_ap_filt_coeff->b2 = pstr_ap_filt_coeff->a0; - } - - return; -} - -WORD32 impd_initialize_filt_bank(WORD32 num_sub_bands, - ia_gain_params_struct* gain_params, - ia_drc_filter_bank_struct* drc_filter_bank) { - ia_two_band_filt_struct* str_two_band_bank; - ia_three_band_filt_struct* str_three_band_bank; - ia_four_band_filt_struct* str_four_band_bank; - drc_filter_bank->complexity = 0; - drc_filter_bank->num_bands = num_sub_bands; - - if (num_sub_bands == 1) { - return 0; - } else if (num_sub_bands == 2) { - str_two_band_bank = &drc_filter_bank->str_two_band_bank; - impd_compute_filt_coeff(gain_params[1].crossover_freq_idx, - &(str_two_band_bank->low_pass), - &(str_two_band_bank->high_pass), NULL, 0); - } else if (num_sub_bands == 3) { - str_three_band_bank = &drc_filter_bank->str_three_band_bank; - - impd_compute_filt_coeff(gain_params[1].crossover_freq_idx, - &(str_three_band_bank->str_low_pass_stage_2), - &(str_three_band_bank->str_high_pass_stage_2), - &(str_three_band_bank->str_all_pass_stage_2), 2); - impd_compute_filt_coeff(gain_params[2].crossover_freq_idx, - &(str_three_band_bank->str_low_pass_stage_1), - &(str_three_band_bank->str_high_pass_stage_1), NULL, - 0); - } - - else if (num_sub_bands == 4) { - str_four_band_bank = &drc_filter_bank->str_four_band_bank; - - impd_compute_filt_coeff(gain_params[1].crossover_freq_idx, - &(str_four_band_bank->str_low_pass_stage_3_low), - &(str_four_band_bank->str_high_pass_stage_3_low), - &(str_four_band_bank->str_all_pass_stage_2_high), - 2); - impd_compute_filt_coeff(gain_params[2].crossover_freq_idx, - &(str_four_band_bank->str_low_pass_stage_1), - &(str_four_band_bank->str_high_pass_stage_1), NULL, - 0); - impd_compute_filt_coeff(gain_params[3].crossover_freq_idx, - &(str_four_band_bank->str_low_pass_stage_3_high), - &(str_four_band_bank->str_high_pass_stage_3_high), - &(str_four_band_bank->str_all_pass_stage_2_low), 2); - } else { - return -1; - } - - return 0; -} - -WORD32 impd_init_all_filter_banks( - ia_uni_drc_coeffs_struct* str_p_loc_drc_coefficients_uni_drc, - ia_drc_instructions_struct* str_drc_instruction_str, - ia_filter_banks_struct* ia_filter_banks_struct) { - WORD32 err_code = 0; - WORD32 b, g, i, k, m, s, crossover_freq_idx, num_ch_in_groups, - num_ph_align_ch_groups; - WORD32 match_found = 0, num_filter; - WORD32 cascade_cross_idx[CHANNEL_GROUP_COUNT_MAX + 1] - [CHANNEL_GROUP_COUNT_MAX * 3]; - WORD32 count[CHANNEL_GROUP_COUNT_MAX + 1]; - - num_ch_in_groups = 0; - num_ph_align_ch_groups = str_drc_instruction_str->num_drc_ch_groups; - - for (g = 0; g < str_drc_instruction_str->num_drc_ch_groups; g++) { - num_ch_in_groups += str_drc_instruction_str->num_chan_per_ch_group[g]; - } - - if (num_ch_in_groups < str_drc_instruction_str->audio_num_chan) { - num_ph_align_ch_groups++; - } - - ia_filter_banks_struct->nfilter_banks = - str_drc_instruction_str->num_drc_ch_groups; - ia_filter_banks_struct->num_ph_align_ch_groups = num_ph_align_ch_groups; - - if (str_p_loc_drc_coefficients_uni_drc == NULL) { - ia_filter_banks_struct->str_drc_filter_bank->num_bands = 1; - } else { - for (g = 0; g < str_drc_instruction_str->num_drc_ch_groups; g++) { - err_code = impd_initialize_filt_bank( - str_p_loc_drc_coefficients_uni_drc - ->gain_set_params[str_drc_instruction_str - ->gain_set_index_for_channel_group[g]] - .band_count, - str_p_loc_drc_coefficients_uni_drc - ->gain_set_params[str_drc_instruction_str - ->gain_set_index_for_channel_group[g]] - .gain_params, - &(ia_filter_banks_struct->str_drc_filter_bank[g])); - if (err_code != 0) return (err_code); - } - } - - for (g = 0; g < CHANNEL_GROUP_COUNT_MAX + 1; g++) { - count[g] = 0; - } - for (g = 0; g < str_drc_instruction_str->num_drc_ch_groups; g++) { - for (b = 1; - b < str_p_loc_drc_coefficients_uni_drc - ->gain_set_params[str_drc_instruction_str - ->gain_set_index_for_channel_group[g]] - .band_count; - b++) { - crossover_freq_idx = - str_p_loc_drc_coefficients_uni_drc - ->gain_set_params[str_drc_instruction_str - ->gain_set_index_for_channel_group[g]] - .gain_params[b] - .crossover_freq_idx; - for (k = 0; k < num_ph_align_ch_groups; k++) { - if (k != g) { - cascade_cross_idx[k][count[k]] = crossover_freq_idx; - count[k]++; - if (count[k] > CHANNEL_GROUP_COUNT_MAX * 3) { - return -1; - } - } - } - } - } - - i = 0; - while (i < count[0]) { - crossover_freq_idx = cascade_cross_idx[0][i]; - match_found = 0; - for (g = 1; g < num_ph_align_ch_groups; g++) { - match_found = 0; - for (k = 0; k < count[g]; k++) { - if (cascade_cross_idx[g][k] == crossover_freq_idx) { - match_found = 1; - break; - } - } - if (match_found == 0) break; - } - if (match_found == 1) { - for (g = 0; g < num_ph_align_ch_groups; g++) { - for (m = 0; m < count[g]; m++) { - if (cascade_cross_idx[g][m] == crossover_freq_idx) { - for (s = m + 1; s < count[g]; s++) { - cascade_cross_idx[g][s - 1] = cascade_cross_idx[g][s]; - } - count[g]--; - break; - } - } - } - i = 0; - } else { - i++; - } - } - - for (g = 0; g < num_ph_align_ch_groups; g++) { - num_filter = count[g]; - if (num_filter > 0) { - for (i = 0; i < num_filter; i++) { - impd_compute_filt_coeff( - cascade_cross_idx[g][i], NULL, NULL, - &(ia_filter_banks_struct->str_drc_filter_bank[g] - .str_all_pass_cascade.str_all_pass_cascade_filter[i] - .str_all_pass_stage), - 1); - } - ia_filter_banks_struct->str_drc_filter_bank[g] - .str_all_pass_cascade.num_filter = num_filter; - } - - if (err_code != 0) return (err_code); - } - - return 0; -} - -VOID impd_iir_second_order_filter_all_pass(ia_iir_filter_struct* filter, - WORD32 chan_idx, WORD32 frame_len, - FLOAT32* input, FLOAT32* output) { - WORD32 i; - FLOAT32 tmp; - FLOAT32 a1 = filter->a1; - FLOAT32 a2 = filter->a2; - FLOAT32 b0 = filter->b0; - FLOAT32 b1 = filter->b1; - FLOAT32 b2 = filter->b2; - - FLOAT32 st1 = filter->x_p[chan_idx * 2]; - FLOAT32 st2 = filter->y_p[chan_idx * 2]; - - for (i = 0; i < frame_len; i++) { - tmp = input[i]; - output[i] = b0 * tmp + st1; - st1 = b1 * tmp - a1 * output[i] + st2; - st2 = b2 * tmp - a2 * output[i]; - } - filter->x_p[chan_idx * 2] = st1; - filter->y_p[chan_idx * 2] = st2; - - return; -} - -VOID impd_apply_low_high_filter(ia_iir_filter_struct* pstr_lp_filt_coeff, - ia_iir_filter_struct* pstr_hp_filt_coeff, - WORD32 chan_idx, WORD32 frame_len, - FLOAT32* input, FLOAT32* output[]) { - WORD32 i; - FLOAT32 tmp, tmp1; - FLOAT32 a1_l = pstr_lp_filt_coeff->a1; - FLOAT32 a2_l = pstr_lp_filt_coeff->a2; - FLOAT32 b0_l = pstr_lp_filt_coeff->b0; - FLOAT32 b1_l = pstr_lp_filt_coeff->b1; - FLOAT32 b2_l = pstr_lp_filt_coeff->b2; - - FLOAT32 st1_l = pstr_lp_filt_coeff->x_p[chan_idx * 2 + 0]; - FLOAT32 st2_l = pstr_lp_filt_coeff->x_p[chan_idx * 2 + 1]; - FLOAT32 st3_l = pstr_lp_filt_coeff->y_p[chan_idx * 2 + 0]; - FLOAT32 st4_l = pstr_lp_filt_coeff->y_p[chan_idx * 2 + 1]; - - FLOAT32 a1_h = pstr_hp_filt_coeff->a1; - FLOAT32 a2_h = pstr_hp_filt_coeff->a2; - FLOAT32 b0_h = pstr_hp_filt_coeff->b0; - FLOAT32 b1_h = pstr_hp_filt_coeff->b1; - FLOAT32 b2_h = pstr_hp_filt_coeff->b2; - - FLOAT32 st1_h = pstr_hp_filt_coeff->x_p[chan_idx * 2 + 0]; - FLOAT32 st2_h = pstr_hp_filt_coeff->x_p[chan_idx * 2 + 1]; - FLOAT32 st3_h = pstr_hp_filt_coeff->y_p[chan_idx * 2 + 0]; - FLOAT32 st4_h = pstr_hp_filt_coeff->y_p[chan_idx * 2 + 1]; - - FLOAT32* output_low = output[0]; - FLOAT32* output_high = output[1]; - - for (i = 0; i < frame_len; i++) { - tmp1 = input[i]; - tmp = b0_l * tmp1 + st1_l; - st1_l = b1_l * tmp1 - a1_l * tmp + st2_l; - st2_l = b2_l * tmp1 - a2_l * tmp; - - output_low[i] = b0_l * tmp + st3_l; - st3_l = b1_l * tmp - a1_l * output_low[i] + st4_l; - st4_l = b2_l * tmp - a2_l * output_low[i]; - - tmp = b0_h * tmp1 + st1_h; - st1_h = b1_h * tmp1 - a1_h * tmp + st2_h; - st2_h = b2_h * tmp1 - a2_h * tmp; - - output_high[i] = b0_h * tmp + st3_h; - st3_h = b1_h * tmp - a1_h * output_high[i] + st4_h; - st4_h = b2_h * tmp - a2_h * output_high[i]; - } - pstr_lp_filt_coeff->x_p[chan_idx * 2 + 0] = st1_l; - pstr_lp_filt_coeff->x_p[chan_idx * 2 + 1] = st2_l; - pstr_lp_filt_coeff->y_p[chan_idx * 2 + 0] = st3_l; - pstr_lp_filt_coeff->y_p[chan_idx * 2 + 1] = st4_l; - - pstr_hp_filt_coeff->x_p[chan_idx * 2 + 0] = st1_h; - pstr_hp_filt_coeff->x_p[chan_idx * 2 + 1] = st2_h; - pstr_hp_filt_coeff->y_p[chan_idx * 2 + 0] = st3_h; - pstr_hp_filt_coeff->y_p[chan_idx * 2 + 1] = st4_h; - - return; -} -VOID impd_two_band_filter_process(ia_two_band_filt_struct* str_two_band_bank, - WORD32 chan_idx, WORD32 frame_len, - FLOAT32* input, FLOAT32* output[]) { - ia_iir_filter_struct* pstr_lp_filt_coeff = &str_two_band_bank->low_pass; - ia_iir_filter_struct* pstr_hp_filt_coeff = &str_two_band_bank->high_pass; - - impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, chan_idx, - frame_len, input, output); - return; -} - -VOID impd_three_band_filter_process( - ia_three_band_filt_struct* str_three_band_bank, WORD32 c, WORD32 size, - FLOAT32* input, FLOAT32* output[]) { - WORD32 err_code = 0; - ia_iir_filter_struct* all_pass_filter; - ia_iir_filter_struct* pstr_lp_filt_coeff = - &str_three_band_bank->str_low_pass_stage_1; - ia_iir_filter_struct* pstr_hp_filt_coeff = - &str_three_band_bank->str_high_pass_stage_1; - FLOAT32* output1[2]; - output1[0] = output[0]; - output1[1] = output[1]; - - impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, c, size, - input, output1); - - all_pass_filter = &str_three_band_bank->str_all_pass_stage_2; - - impd_iir_second_order_filter_all_pass(all_pass_filter, c, size, output1[1], - output[2]); - pstr_lp_filt_coeff = &str_three_band_bank->str_low_pass_stage_2; - pstr_hp_filt_coeff = &str_three_band_bank->str_high_pass_stage_2; - - impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, c, size, - output1[0], output1); - - return; -} - -VOID impd_four_band_filter_process(ia_four_band_filt_struct* str_four_band_bank, - WORD32 cha_idx, WORD32 win_size, - FLOAT32* input, FLOAT32* output[]) { - WORD32 err_code = 0; - ia_iir_filter_struct* all_pass_filter; - ia_iir_filter_struct* pstr_lp_filt_coeff = - &str_four_band_bank->str_low_pass_stage_1; - ia_iir_filter_struct* pstr_hp_filt_coeff = - &str_four_band_bank->str_high_pass_stage_1; - FLOAT32* output1[2]; - FLOAT32* output2[2]; - output1[0] = output[0]; - output1[1] = output[1]; - output2[0] = output[2]; - output2[1] = output[3]; - - impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, - win_size, input, output1); - - all_pass_filter = &str_four_band_bank->str_all_pass_stage_2_low; - - impd_iir_second_order_filter_all_pass(all_pass_filter, cha_idx, win_size, - output1[0], output1[0]); - - all_pass_filter = &str_four_band_bank->str_all_pass_stage_2_high; - - impd_iir_second_order_filter_all_pass(all_pass_filter, cha_idx, win_size, - output1[1], output2[0]); - - pstr_lp_filt_coeff = &str_four_band_bank->str_low_pass_stage_3_low; - pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_low; - - impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, - win_size, output1[0], output1); - - pstr_lp_filt_coeff = &str_four_band_bank->str_low_pass_stage_3_high; - pstr_hp_filt_coeff = &str_four_band_bank->str_high_pass_stage_3_high; - - impd_apply_low_high_filter(pstr_lp_filt_coeff, pstr_hp_filt_coeff, cha_idx, - win_size, output2[0], output2); - - return; -} - -VOID impd_all_pass_cascade_process( - ia_all_pass_cascade_struct* str_all_pass_cascade, WORD32 ch_idx, - WORD32 win_size, FLOAT32* input) { - WORD32 i; - - for (i = 0; i < str_all_pass_cascade->num_filter; i++) { - impd_iir_second_order_filter_all_pass( - &(str_all_pass_cascade->str_all_pass_cascade_filter[i] - .str_all_pass_stage), - ch_idx, win_size, input, input); - } - - return; -}
\ No newline at end of file diff --git a/decoder/drc_src/impd_drc_gain_dec.c b/decoder/drc_src/impd_drc_gain_dec.c index accce93..f3486fe 100644 --- a/decoder/drc_src/impd_drc_gain_dec.c +++ b/decoder/drc_src/impd_drc_gain_dec.c @@ -34,7 +34,7 @@ #include "impd_drc_eq.h" #include "impd_drc_gain_decoder.h" -extern ia_cicp_sigmoid_characteristic_param_struct +extern const ia_cicp_sigmoid_characteristic_param_struct pstr_cicp_sigmoid_characteristic_param[]; WORD32 impd_gain_db_to_lin(ia_interp_params_struct* interp_params_str, @@ -433,15 +433,15 @@ WORD32 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, return (UNEXPECTED_ERROR); } + err = impd_conv_to_linear_domain(interp_params_str, drc_band, gain0, slope0, + &gain_t1, &slope_t1); + if (err) return (err); + err = impd_conv_to_linear_domain(interp_params_str, drc_band, gain1, slope1, + &gain_t2, &slope_t2); + if (err) return (err); + if (interp_params_str->gain_interpolation_type == GAIN_INTERPOLATION_TYPE_SPLINE) { - err = impd_conv_to_linear_domain(interp_params_str, drc_band, gain0, slope0, - &gain_t1, &slope_t1); - if (err) return (err); - err = impd_conv_to_linear_domain(interp_params_str, drc_band, gain1, slope1, - &gain_t2, &slope_t2); - if (err) return (err); - slope_t1 = slope_t1 / (FLOAT32)interp_params_str->delta_tmin; slope_t2 = slope_t2 / (FLOAT32)interp_params_str->delta_tmin; if ((FLOAT32)fabs((FLOAT64)slope_t1) > (FLOAT32)fabs((FLOAT64)slope_t2)) { @@ -522,14 +522,9 @@ WORD32 impd_interpolate_drc_gain(ia_interp_params_struct* interp_params_str, } } } else { - err = impd_conv_to_linear_domain(interp_params_str, drc_band, gain1, slope1, - &gain_t2, &slope_t2); - if (err) return (err); - - a = 0; - b = gain_t2; - - result[0] = gain_t2; + a = (gain_t2 - gain_t1) / (FLOAT32)gain_step_tdomain; + b = gain_t1; + result[0] = gain_t1; result[gain_step_tdomain] = gain_t2; for (n = 1; n < gain_step_tdomain; n++) { FLOAT32 t = (FLOAT32)n; diff --git a/decoder/drc_src/impd_drc_gain_decoder.c b/decoder/drc_src/impd_drc_gain_decoder.c index 829f576..c9d29ea 100644 --- a/decoder/drc_src/impd_drc_gain_decoder.c +++ b/decoder/drc_src/impd_drc_gain_decoder.c @@ -380,76 +380,6 @@ IA_ERRORCODE impd_drc_process_time_domain( return err_code; } -IA_ERRORCODE impd_drc_process_freq_domain( - ia_drc_gain_dec_struct* p_drc_gain_dec_structs, - ia_drc_config* pstr_drc_config, ia_drc_gain_struct* pstr_drc_gain, - FLOAT32* audio_real_buff[], FLOAT32* audio_imag_buff[], - FLOAT32 loudness_normalization_gain_db, FLOAT32 boost, FLOAT32 compress, - WORD32 drc_characteristic_target) { - WORD32 sel_drc_index; - IA_ERRORCODE err_code = 0; - ia_drc_instructions_struct* str_drc_instruction_str = - pstr_drc_config->str_drc_instruction_str; - - if (p_drc_gain_dec_structs->eq_set) { - WORD32 ch; - - for (ch = 0; ch < p_drc_gain_dec_structs->eq_set->audio_num_chan; ch++) { - err_code = impd_process_eq_set_subband_domain( - p_drc_gain_dec_structs->eq_set, ch, audio_real_buff[ch], - audio_imag_buff[ch]); - if (err_code != IA_NO_ERROR) return (err_code); - } - } - err_code = impd_store_audio_io_buffer_freq( - audio_real_buff, audio_imag_buff, - &p_drc_gain_dec_structs->audio_in_out_buf); - if (err_code != IA_NO_ERROR) return (err_code); - - if (pstr_drc_config->apply_drc) { - for (sel_drc_index = 0; - sel_drc_index < - p_drc_gain_dec_structs->ia_drc_params_struct.drc_set_counter; - sel_drc_index++) { - err_code = impd_get_drc_gain( - p_drc_gain_dec_structs, pstr_drc_config, pstr_drc_gain, compress, - boost, drc_characteristic_target, loudness_normalization_gain_db, - sel_drc_index, &p_drc_gain_dec_structs->drc_gain_buffers); - if (err_code != IA_NO_ERROR) return (err_code); - } - - if (p_drc_gain_dec_structs->ia_drc_params_struct.drc_set_counter == 0) { - err_code = impd_retrieve_audio_buffer_freq( - audio_real_buff, audio_imag_buff, - &p_drc_gain_dec_structs->audio_in_out_buf); - if (err_code != IA_NO_ERROR) return (err_code); - } else { - for (sel_drc_index = 0; - sel_drc_index < - p_drc_gain_dec_structs->ia_drc_params_struct.drc_set_counter; - sel_drc_index++) { - err_code = impd_apply_gains_subband( - str_drc_instruction_str, - p_drc_gain_dec_structs->ia_drc_params_struct - .sel_drc_array[sel_drc_index] - .drc_instructions_index, - &p_drc_gain_dec_structs->ia_drc_params_struct, - &(p_drc_gain_dec_structs->drc_gain_buffers - .pstr_gain_buf[sel_drc_index]), - &p_drc_gain_dec_structs->str_overlap_params, - p_drc_gain_dec_structs->audio_in_out_buf.audio_buffer_delayed_real, - p_drc_gain_dec_structs->audio_in_out_buf.audio_buffer_delayed_imag, - audio_real_buff, audio_imag_buff); - if (err_code != IA_NO_ERROR) return (err_code); - } - } - } - - err_code = - impd_advance_audio_buff_freq(&p_drc_gain_dec_structs->audio_in_out_buf); - - return err_code; -} VOID impd_get_parametric_drc_delay( ia_drc_gain_dec_struct* p_drc_gain_dec_structs, diff --git a/decoder/drc_src/impd_drc_host_params.c b/decoder/drc_src/impd_drc_host_params.c deleted file mode 100644 index 0cfe0df..0000000 --- a/decoder/drc_src/impd_drc_host_params.c +++ /dev/null @@ -1,197 +0,0 @@ -/****************************************************************************** - * - * 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 <stdio.h> -#include "impd_type_def.h" -#include "impd_drc_extr_delta_coded_info.h" -#include "impd_drc_common.h" -#include "impd_drc_struct.h" -#include "impd_drc_interface.h" -#include "impd_drc_selection_process.h" -#include "impd_drc_filter_bank.h" -#include "impd_drc_rom.h" - -WORD32 impd_set_default_params_selection_process( - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params) { - pstr_drc_sel_proc_params->base_channel_count = -1; - pstr_drc_sel_proc_params->base_layout = -1; - pstr_drc_sel_proc_params->target_config_request_type = 0; - pstr_drc_sel_proc_params->num_downmix_id_requests = 0; - - pstr_drc_sel_proc_params->album_mode = 0; - - pstr_drc_sel_proc_params->peak_limiter = 1; - - pstr_drc_sel_proc_params->loudness_normalization_on = 0; - pstr_drc_sel_proc_params->target_loudness = -24.0f; - - pstr_drc_sel_proc_params->loudness_deviation_max = - LOUDNESS_DEVIATION_MAX_DEFAULT; - - pstr_drc_sel_proc_params->loudness_measurement_method = - USER_METHOD_DEFINITION_DEFAULT; - pstr_drc_sel_proc_params->loudness_measurement_system = - USER_MEASUREMENT_SYSTEM_DEFAULT; - pstr_drc_sel_proc_params->loudness_measurement_pre_proc = - USER_LOUDNESS_PREPROCESSING_DEFAULT; - pstr_drc_sel_proc_params->device_cut_off_frequency = 500; - pstr_drc_sel_proc_params->loudness_norm_gain_db_max = - LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; - pstr_drc_sel_proc_params->loudness_norm_gain_modification_db = 0.0f; - pstr_drc_sel_proc_params->output_peak_level_max = 0.0f; - if (pstr_drc_sel_proc_params->peak_limiter == 1) { - pstr_drc_sel_proc_params->output_peak_level_max = 6.0f; - } - - pstr_drc_sel_proc_params->dynamic_range_control_on = 1; - pstr_drc_sel_proc_params->num_bands_supported = 4; - pstr_drc_sel_proc_params->num_drc_feature_requests = 0; - - pstr_drc_sel_proc_params->boost = 1.f; - pstr_drc_sel_proc_params->compress = 1.f; - pstr_drc_sel_proc_params->drc_characteristic_target = 0; - - return 0; -} -WORD32 impd_set_custom_params( - const WORD32 param_set_idx, - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params) { - WORD32 i, k; - - const ia_loc_sys_interface_struct* system_interface = - &(loc_sys_interface[param_set_idx - 1]); - - const ia_loc_loudness_norm_ctrl_interface_struct* - loudness_norm_ctrl_interface = - &(loc_loudness_norm_ctrl_interface[param_set_idx - 1]); - const ia_loc_loudness_norm_param_interface_struct* - loudness_norm_param_interface = - &(loc_loudness_norm_param_interface[param_set_idx - 1]); - - const ia_loc_drc_interface_struct* drc_ctrl_interface = - &(loc_dyn_range_ctrl_interface[param_set_idx - 1]); - const ia_loc_requested_drc_effect_struct* requested_drc_effect_type = - &(loc_requested_drc_effect_type_str[param_set_idx - 1]); - const ia_loc_drc_parameter_interface_struct* drc_parameter_interface = - &(loc_drc_parameter_interface[param_set_idx - 1]); - - pstr_drc_sel_proc_params->target_config_request_type = - system_interface->target_config_request_type; - switch (system_interface->target_config_request_type) { - case 1: - pstr_drc_sel_proc_params->requested_target_layout = - system_interface->requested_target_layout; - break; - case 2: - pstr_drc_sel_proc_params->requested_target_ch_count = - system_interface->requested_target_ch_count; - break; - case 0: - default: - pstr_drc_sel_proc_params->num_downmix_id_requests = - system_interface->num_downmix_id_requests; - for (i = 0; i < system_interface->num_downmix_id_requests; i++) { - pstr_drc_sel_proc_params->requested_dwnmix_id[i] = - system_interface->requested_dwnmix_id[i]; - } - break; - } - - pstr_drc_sel_proc_params->loudness_normalization_on = - loudness_norm_ctrl_interface->loudness_normalization_on; - pstr_drc_sel_proc_params->target_loudness = - loudness_norm_ctrl_interface->target_loudness; - - pstr_drc_sel_proc_params->album_mode = - loudness_norm_param_interface->album_mode; - pstr_drc_sel_proc_params->peak_limiter = - loudness_norm_param_interface->peak_limiter; - pstr_drc_sel_proc_params->loudness_deviation_max = - loudness_norm_param_interface->loudness_deviation_max; - pstr_drc_sel_proc_params->loudness_measurement_method = - loudness_norm_param_interface->loudness_measurement_method; - pstr_drc_sel_proc_params->loudness_measurement_system = - loudness_norm_param_interface->loudness_measurement_system; - pstr_drc_sel_proc_params->loudness_measurement_pre_proc = - loudness_norm_param_interface->loudness_measurement_pre_proc; - pstr_drc_sel_proc_params->device_cut_off_frequency = - loudness_norm_param_interface->device_cut_off_frequency; - pstr_drc_sel_proc_params->loudness_norm_gain_db_max = - loudness_norm_param_interface->loudness_norm_gain_db_max; - pstr_drc_sel_proc_params->loudness_norm_gain_modification_db = - loudness_norm_param_interface->loudness_norm_gain_modification_db; - pstr_drc_sel_proc_params->output_peak_level_max = - loudness_norm_param_interface->output_peak_level_max; - - pstr_drc_sel_proc_params->dynamic_range_control_on = - drc_ctrl_interface->dynamic_range_control_on; - pstr_drc_sel_proc_params->num_drc_feature_requests = - drc_ctrl_interface->num_drc_feature_requests; - for (i = 0; i < drc_ctrl_interface->num_drc_feature_requests; i++) { - pstr_drc_sel_proc_params->drc_feature_req_type[i] = - drc_ctrl_interface->drc_feature_req_type[i]; - switch (drc_ctrl_interface->drc_feature_req_type[i]) { - case MATCH_EFFECT_TYPE: - pstr_drc_sel_proc_params->requested_num_drc_effects[i] = - requested_drc_effect_type->requested_num_drc_effects; - pstr_drc_sel_proc_params->desired_num_drc_effects_of_requested[i] = - requested_drc_effect_type->desired_num_drc_effects_of_requested; - for (k = 0; k < requested_drc_effect_type->requested_num_drc_effects; - k++) { - pstr_drc_sel_proc_params->requested_drc_effect_type[i][k] = - requested_drc_effect_type->requested_drc_effect_type[k]; - } - break; - case MATCH_DYNAMIC_RANGE: - pstr_drc_sel_proc_params->requested_dyn_range_measur_type[i] = - drc_ctrl_interface->requested_dyn_rng_measurement_type; - pstr_drc_sel_proc_params->requested_dyn_range_range_flag[i] = - drc_ctrl_interface->requested_dyn_range_is_single_val_flag; - pstr_drc_sel_proc_params->requested_dyn_range_value[i] = - drc_ctrl_interface->requested_dyn_range_value; - pstr_drc_sel_proc_params->requested_dyn_range_min_val[i] = - drc_ctrl_interface->requested_dyn_range_min_val; - pstr_drc_sel_proc_params->requested_dyn_range_max_val[i] = - drc_ctrl_interface->requested_dyn_range_max_val; - break; - case MATCH_DRC_CHARACTERISTIC: - pstr_drc_sel_proc_params->requested_drc_characteristic[i] = - drc_ctrl_interface->requested_drc_characteristic; - break; - default: - return (UNEXPECTED_ERROR); - } - } - - pstr_drc_sel_proc_params->boost = drc_parameter_interface->boost; - pstr_drc_sel_proc_params->compress = drc_parameter_interface->compress; - pstr_drc_sel_proc_params->drc_characteristic_target = - drc_parameter_interface->drc_characteristic_target; - - return (0); -} -WORD32 impd_eval_custom_params_selection_process( - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params) { - pstr_drc_sel_proc_params->loudness_norm_gain_db_max = - max(0.0f, pstr_drc_sel_proc_params->loudness_norm_gain_db_max); - pstr_drc_sel_proc_params->loudness_deviation_max = - max(0, pstr_drc_sel_proc_params->loudness_deviation_max); - - return (0); -} diff --git a/decoder/drc_src/impd_drc_host_params.h b/decoder/drc_src/impd_drc_host_params.h deleted file mode 100644 index 9c71245..0000000 --- a/decoder/drc_src/impd_drc_host_params.h +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - * - * 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 -*/ -#ifndef IMPD_DRC_HOST_PARAMS_H -#define IMPD_DRC_HOST_PARAMS_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -WORD32 impd_set_default_params_selection_process( - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params); - -WORD32 impd_set_custom_params( - const WORD32 param_set_idx, - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params); - -WORD32 impd_eval_custom_params_selection_process( - ia_drc_sel_proc_params_struct* pstr_drc_sel_proc_params); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/decoder/drc_src/impd_drc_init.c b/decoder/drc_src/impd_drc_init.c index b4711c8..3e0d622 100644 --- a/decoder/drc_src/impd_drc_init.c +++ b/decoder/drc_src/impd_drc_init.c @@ -41,7 +41,6 @@ #include "impd_drc_selection_process.h" #include "impd_drc_api_struct_def.h" #include "impd_drc_peak_limiter.h" -#include "impd_drc_host_params.h" #define PARAMETRIC_DRC_DELAY_MAX_DEFAULT 4096 #define EQ_DELAY_MAX_DEFAULT 256 @@ -90,7 +89,7 @@ static WORD32 impd_match_downmix(WORD32 downmix_id, WORD32 dec_downmix_id) { IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc) { memset(p_obj_drc, 0, sizeof(*p_obj_drc)); - p_obj_drc->str_config.bitstream_file_format = 0; + p_obj_drc->str_config.bitstream_file_format = 1; p_obj_drc->str_config.dec_type = 0; p_obj_drc->str_config.sub_band_domain_mode = 0; p_obj_drc->str_config.sub_band_count = 0; @@ -102,10 +101,11 @@ IA_ERRORCODE impd_drc_set_default_config(ia_drc_api_struct *p_obj_drc) { p_obj_drc->str_config.control_parameter_index = -1; p_obj_drc->str_config.peak_limiter = 0; p_obj_drc->str_config.delay_mode = 0; - p_obj_drc->str_config.interface_bitstream_present = 0; + p_obj_drc->str_config.interface_bitstream_present = 1; p_obj_drc->str_config.gain_delay_samples = 0; p_obj_drc->str_config.absorb_delay_on = 1; p_obj_drc->str_config.subband_domain_io_flag = 0; + p_obj_drc->str_bit_handler.gain_stream_flag = 1; p_obj_drc->str_config.constant_delay_on = 0; p_obj_drc->str_config.audio_delay_samples = 0; p_obj_drc->str_config.effect_type = 0; @@ -274,79 +274,85 @@ IA_ERRORCODE impd_drc_set_default_bitstream_config( } IA_ERRORCODE impd_drc_set_struct_pointer(ia_drc_api_struct *p_obj_drc) { - SIZE_T persistant_ptr = (SIZE_T)p_obj_drc->p_state->persistant_ptr; + SIZE_T persistent_ptr = (SIZE_T)p_obj_drc->p_state->persistent_ptr; + SIZE_T persistent_size_consumed = 0; p_obj_drc->str_payload.pstr_bitstream_dec = - (ia_drc_bits_dec_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_bits_dec_struct); + (ia_drc_bits_dec_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_bits_dec_struct); p_obj_drc->str_payload.pstr_gain_dec[0] = - (ia_drc_gain_dec_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_gain_dec_struct); + (ia_drc_gain_dec_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_gain_dec_struct); p_obj_drc->str_payload.pstr_gain_dec[1] = - (ia_drc_gain_dec_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_gain_dec_struct); + (ia_drc_gain_dec_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_gain_dec_struct); p_obj_drc->str_payload.pstr_loudness_info = - (ia_drc_loudness_info_set_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_loudness_info_set_struct); + (ia_drc_loudness_info_set_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_loudness_info_set_struct); - p_obj_drc->str_payload.pstr_drc_gain = (ia_drc_gain_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_gain_struct); + p_obj_drc->str_payload.pstr_drc_gain = (ia_drc_gain_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_gain_struct); p_obj_drc->str_payload.pstr_drc_interface = - (ia_drc_interface_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_interface_struct); + (ia_drc_interface_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_interface_struct); - p_obj_drc->str_payload.pstr_drc_config = (ia_drc_config *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_config); + p_obj_drc->str_payload.pstr_drc_config = (ia_drc_config *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_config); p_obj_drc->str_payload.pstr_selection_proc = - (ia_drc_sel_pro_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_sel_pro_struct); + (ia_drc_sel_pro_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_sel_pro_struct); - p_obj_drc->str_bit_handler.it_bit_buf = (UWORD8 *)persistant_ptr; - persistant_ptr = persistant_ptr + MAX_BS_BUF_SIZE; + p_obj_drc->str_bit_handler.it_bit_buf = (UWORD8 *)persistent_ptr; + persistent_ptr = persistent_ptr + MAX_DRC_BS_BUF_SIZE; p_obj_drc->str_payload.pstr_drc_sel_proc_params = - (ia_drc_sel_proc_params_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_sel_proc_params_struct); + (ia_drc_sel_proc_params_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_sel_proc_params_struct); p_obj_drc->str_payload.pstr_drc_sel_proc_output = - (ia_drc_sel_proc_output_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_sel_proc_output_struct); + (ia_drc_sel_proc_output_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_sel_proc_output_struct); - p_obj_drc->str_bit_handler.bitstream_drc_config = (UWORD8 *)persistant_ptr; - persistant_ptr = persistant_ptr + MAX_BS_BUF_SIZE; + p_obj_drc->str_bit_handler.bitstream_drc_config = (UWORD8 *)persistent_ptr; + persistent_ptr = persistent_ptr + MAX_BS_BUF_SIZE; - p_obj_drc->str_bit_handler.bitstream_loudness_info = (UWORD8 *)persistant_ptr; - persistant_ptr = persistant_ptr + MAX_BS_BUF_SIZE; + p_obj_drc->str_bit_handler.bitstream_loudness_info = (UWORD8 *)persistent_ptr; + persistent_ptr = persistent_ptr + MAX_BS_BUF_SIZE; p_obj_drc->str_bit_handler.bitstream_unidrc_interface = - (UWORD8 *)persistant_ptr; - persistant_ptr = persistant_ptr + MAX_BS_BUF_SIZE; + (UWORD8 *)persistent_ptr; + persistent_ptr = persistent_ptr + MAX_BS_BUF_SIZE; p_obj_drc->str_payload.pstr_peak_limiter = - (ia_drc_peak_limiter_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_peak_limiter_struct); + (ia_drc_peak_limiter_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_peak_limiter_struct); p_obj_drc->str_payload.pstr_peak_limiter->buffer = (FLOAT32 *)((SIZE_T)p_obj_drc->str_payload.pstr_peak_limiter + sizeof(ia_drc_peak_limiter_struct)); - persistant_ptr = persistant_ptr + PEAK_LIM_BUF_SIZE; + persistent_ptr = persistent_ptr + PEAK_LIM_BUF_SIZE; p_obj_drc->str_payload.pstr_qmf_filter = - (ia_drc_qmf_filt_struct *)persistant_ptr; - persistant_ptr = persistant_ptr + sizeof(ia_drc_qmf_filt_struct); + (ia_drc_qmf_filt_struct *)persistent_ptr; + persistent_ptr = persistent_ptr + sizeof(ia_drc_qmf_filt_struct); - p_obj_drc->str_payload.pstr_qmf_filter->ana_buff = (FLOAT64 *)persistant_ptr; - persistant_ptr = persistant_ptr + ANALY_BUF_SIZE; + p_obj_drc->str_payload.pstr_qmf_filter->ana_buff = (FLOAT64 *)persistent_ptr; + persistent_ptr = persistent_ptr + ANALY_BUF_SIZE; - p_obj_drc->str_payload.pstr_qmf_filter->syn_buff = (FLOAT64 *)persistant_ptr; - persistant_ptr = persistant_ptr + SYNTH_BUF_SIZE; + p_obj_drc->str_payload.pstr_qmf_filter->syn_buff = (FLOAT64 *)persistent_ptr; + persistent_ptr = persistent_ptr + SYNTH_BUF_SIZE; + persistent_size_consumed = + (UWORD32)persistent_ptr - (UWORD32)p_obj_drc->p_state->persistent_ptr; + if (p_obj_drc->p_mem_info[IA_MEMTYPE_PERSIST].ui_size < + persistent_size_consumed) + return IA_FATAL_ERROR; - p_obj_drc->p_state->persistant_ptr = (pVOID)persistant_ptr; + p_obj_drc->p_state->persistent_ptr = (pVOID)persistent_ptr; return IA_NO_ERROR; } @@ -373,7 +379,7 @@ IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc) { IA_ERRORCODE err_code = IA_NO_ERROR; WORD32 i, j; - pVOID persistant_ptr = p_obj_drc->p_state->persistant_ptr; + pVOID persistent_ptr = p_obj_drc->p_state->persistent_ptr; struct ia_bit_buf_struct *it_bit_buff; @@ -401,99 +407,52 @@ IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc) { p_obj_drc->str_payload.pstr_gain_dec[i]); } - if (p_obj_drc->str_config.interface_bitstream_present) { - err_code = impd_drc_dec_interface_add_effect_type( - p_obj_drc->str_payload.pstr_drc_interface, - p_obj_drc->str_config.effect_type, - p_obj_drc->str_config.target_loudness, - p_obj_drc->str_config.loud_norm_flag); - - if (err_code != IA_NO_ERROR) return err_code; - - err_code = impd_drc_uni_selction_proc_init( - p_obj_drc->str_payload.pstr_selection_proc, 0, - p_obj_drc->str_payload.pstr_drc_interface, - p_obj_drc->str_config.sub_band_domain_mode); - if (err_code != IA_NO_ERROR) return err_code; - - if (p_obj_drc->str_payload.pstr_drc_interface - ->loudness_norm_parameter_interface_flag && - p_obj_drc->str_payload.pstr_drc_interface->loudness_norm_param_interface - .peak_limiter) { - p_obj_drc->str_config.peak_limiter = 1; - } - } else { - err_code = impd_set_default_params_selection_process( - p_obj_drc->str_payload.pstr_drc_sel_proc_params); - if (err_code != IA_NO_ERROR) return err_code; - err_code = - impd_set_custom_params(p_obj_drc->str_config.control_parameter_index, - p_obj_drc->str_payload.pstr_drc_sel_proc_params); - if (err_code != IA_NO_ERROR) return err_code; - err_code = impd_eval_custom_params_selection_process( - p_obj_drc->str_payload.pstr_drc_sel_proc_params); - if (err_code != IA_NO_ERROR) return err_code; - err_code = impd_drc_uni_selction_proc_init( - p_obj_drc->str_payload.pstr_selection_proc, - p_obj_drc->str_payload.pstr_drc_sel_proc_params, 0, - p_obj_drc->str_config.sub_band_domain_mode); - if (err_code != IA_NO_ERROR) return err_code; - - if (p_obj_drc->str_payload.pstr_drc_sel_proc_params->peak_limiter) { - p_obj_drc->str_config.peak_limiter = 1; - } + err_code = impd_drc_dec_interface_add_effect_type( + p_obj_drc->str_payload.pstr_drc_interface, + p_obj_drc->str_config.effect_type, p_obj_drc->str_config.target_loudness, + p_obj_drc->str_config.loud_norm_flag); + + if (err_code != IA_NO_ERROR) return err_code; + + err_code = impd_drc_uni_selction_proc_init( + p_obj_drc->str_payload.pstr_selection_proc, 0, + p_obj_drc->str_payload.pstr_drc_interface, + p_obj_drc->str_config.sub_band_domain_mode); + if (err_code != IA_NO_ERROR) return err_code; + + if (p_obj_drc->str_payload.pstr_drc_interface + ->loudness_norm_parameter_interface_flag && + p_obj_drc->str_payload.pstr_drc_interface->loudness_norm_param_interface + .peak_limiter) { + p_obj_drc->str_config.peak_limiter = 1; } + p_obj_drc->str_payload.pstr_loudness_info->loudness_info_album_count = 0; p_obj_drc->str_payload.pstr_loudness_info->loudness_info_count = 0; p_obj_drc->str_payload.pstr_loudness_info->loudness_info_set_ext_present = 0; p_obj_drc->p_state->ui_exe_done = 0; - if (p_obj_drc->str_config.bitstream_file_format == - BITSTREAM_FILE_FORMAT_SPLIT) { - err_code = impd_process_drc_bitstream_dec_config( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - &p_obj_drc->str_bit_handler.bitstream_drc_config[0], - p_obj_drc->str_bit_handler.num_bytes_bs_drc_config); - - if (err_code == 1) { - memset(p_obj_drc->str_payload.pstr_drc_config, 0, sizeof(ia_drc_config)); - err_code = impd_drc_set_default_bitstream_config( - p_obj_drc->str_payload.pstr_drc_config); - p_obj_drc->str_payload.pstr_drc_config->channel_layout - .base_channel_count = p_obj_drc->str_config.num_ch_in; - } - - if (err_code != IA_NO_ERROR) return err_code; - err_code = impd_process_drc_bitstream_dec_loudness_info_set( - p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_loudness_info, - &p_obj_drc->str_bit_handler.bitstream_loudness_info[0], - p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info); - if (err_code != IA_NO_ERROR) return err_code; - - } else { - err_code = impd_process_drc_bitstream_dec( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_loudness_info, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (err_code > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; + err_code = impd_process_drc_bitstream_dec_config( + p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, + p_obj_drc->str_payload.pstr_drc_config, + &p_obj_drc->str_bit_handler.bitstream_drc_config[0], + p_obj_drc->str_bit_handler.num_bytes_bs_drc_config); + + if (err_code == 1) { + memset(p_obj_drc->str_payload.pstr_drc_config, 0, sizeof(ia_drc_config)); + err_code = impd_drc_set_default_bitstream_config( + p_obj_drc->str_payload.pstr_drc_config); + p_obj_drc->str_payload.pstr_drc_config->channel_layout.base_channel_count = + p_obj_drc->str_config.num_ch_in; } + if (err_code != IA_NO_ERROR) return err_code; + err_code = impd_process_drc_bitstream_dec_loudness_info_set( + p_obj_drc->pstr_bit_buf, p_obj_drc->str_payload.pstr_loudness_info, + &p_obj_drc->str_bit_handler.bitstream_loudness_info[0], + p_obj_drc->str_bit_handler.num_bytes_bs_loudness_info); + if (err_code != IA_NO_ERROR) return err_code; + err_code = impd_drc_uni_sel_proc_process( p_obj_drc->str_payload.pstr_selection_proc, p_obj_drc->str_payload.pstr_drc_config, @@ -538,7 +497,7 @@ IA_ERRORCODE impd_drc_init(ia_drc_api_struct *p_obj_drc) { , p_obj_drc->str_payload.pstr_gain_dec[i], p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_loudness_info, &persistant_ptr); + p_obj_drc->str_payload.pstr_loudness_info, &persistent_ptr); impd_get_parametric_drc_delay( p_obj_drc->str_payload.pstr_gain_dec[i], diff --git a/decoder/drc_src/impd_drc_interface_decoder.c b/decoder/drc_src/impd_drc_interface_decoder.c index 35b1f3c..4e0301c 100644 --- a/decoder/drc_src/impd_drc_interface_decoder.c +++ b/decoder/drc_src/impd_drc_interface_decoder.c @@ -30,29 +30,6 @@ #include "impd_drc_parser_interface.h" WORD32 -impd_drc_dec_interface_process(ia_bit_buf_struct* it_bit_buff, - ia_drc_interface_struct* pstr_drc_interface, - UWORD8* it_bit_buf, WORD32 num_bit_stream_bits, - WORD32* num_bits_read) { - WORD32 err = 0; - - if (it_bit_buff != NULL && num_bit_stream_bits) { - it_bit_buff = impd_create_init_bit_buf(it_bit_buff, it_bit_buf, - num_bit_stream_bits / 8); - - } else { - return -1; - } - - err = impd_unidrc_interface_read(it_bit_buff, pstr_drc_interface); - if (err) return (err); - - *num_bits_read = (it_bit_buff->size) - it_bit_buff->cnt_bits; - - return err; -} - -WORD32 impd_drc_dec_interface_add_effect_type( ia_drc_interface_struct* pstr_drc_interface, WORD32 drc_effect_type, WORD32 target_loudness, WORD32 loud_norm) { diff --git a/decoder/drc_src/impd_drc_interface_parser.c b/decoder/drc_src/impd_drc_interface_parser.c deleted file mode 100644 index 1ae69a2..0000000 --- a/decoder/drc_src/impd_drc_interface_parser.c +++ /dev/null @@ -1,514 +0,0 @@ -/****************************************************************************** - * - * 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 <stdio.h> -#include <string.h> -#include <math.h> - -#include "impd_type_def.h" -#include "impd_drc_bitbuffer.h" -#include "impd_drc_common.h" -#include "impd_drc_interface.h" -#include "impd_drc_extr_delta_coded_info.h" -#include "impd_drc_struct.h" - -WORD32 impd_unidrc_interface_signature_read( - ia_bit_buf_struct* it_bit_buff, - ia_drc_uni_interface_signat_struct* drc_uni_interface_signature) { - // WORD32 err = 0 - WORD32 interface_signat_data_len = 0, i, tmp; - - tmp = impd_read_bits_buf(it_bit_buff, 16); - if (it_bit_buff->error) return it_bit_buff->error; - - drc_uni_interface_signature->interface_signat_type = (tmp >> 8) & 0xff; - drc_uni_interface_signature->interface_signat_data_len = tmp & 0xff; - - interface_signat_data_len = - drc_uni_interface_signature->interface_signat_data_len + 1; - for (i = 0; i < interface_signat_data_len; i++) { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - drc_uni_interface_signature->interface_signat_data[i] = (UWORD32)tmp; - } - - return (0); -} -WORD32 impd_sys_interface_read(ia_bit_buf_struct* it_bit_buff, - ia_system_interface_struct* system_interface) { - // WORD32 err = 0; - WORD32 i = 0, tmp = 0; - - system_interface->target_config_request_type = - impd_read_bits_buf(it_bit_buff, 2); - if (it_bit_buff->error) return it_bit_buff->error; - - switch (system_interface->target_config_request_type) { - case 0: - system_interface->num_downmix_id_requests = - impd_read_bits_buf(it_bit_buff, 4); - if (it_bit_buff->error) return it_bit_buff->error; - - if (system_interface->num_downmix_id_requests == 0) { - system_interface->num_downmix_id_requests = 1; - system_interface->requested_dwnmix_id[0] = 0; - break; - } - for (i = 0; i < system_interface->num_downmix_id_requests; i++) { - system_interface->requested_dwnmix_id[i] = - impd_read_bits_buf(it_bit_buff, 7); - if (it_bit_buff->error) return it_bit_buff->error; - } - break; - case 1: - system_interface->requested_target_layout = - impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - break; - case 2: - tmp = impd_read_bits_buf(it_bit_buff, 7); - if (it_bit_buff->error) return it_bit_buff->error; - system_interface->requested_target_ch_count = tmp + 1; - break; - default: - return (1); - break; - } - return (0); -} - -WORD32 impd_loudness_norm_control_interface_read( - ia_bit_buf_struct* it_bit_buff, - ia_loudness_norm_ctrl_interface_struct* loudness_norm_ctrl_interface) { - // WORD32 err = 0; - WORD32 tmp = 0; - - loudness_norm_ctrl_interface->loudness_normalization_on = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - - if (loudness_norm_ctrl_interface->loudness_normalization_on == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 12); - if (it_bit_buff->error) return it_bit_buff->error; - loudness_norm_ctrl_interface->target_loudness = -tmp * 0.03125f; - } - return (0); -} - -WORD32 impd_loudness_norm_param_interface_read( - ia_bit_buf_struct* it_bit_buff, ia_loudness_norm_parameter_interface_struct* - loudness_norm_param_interface) { - // WORD32 err = 0; - WORD32 tmp = 0; - - tmp = impd_read_bits_buf(it_bit_buff, 3); - if (it_bit_buff->error) return it_bit_buff->error; - - loudness_norm_param_interface->album_mode = (tmp >> 2) & 1; - loudness_norm_param_interface->peak_limiter = (tmp >> 1) & 1; - loudness_norm_param_interface->change_loudness_deviation_max = tmp & 1; - - if (loudness_norm_param_interface->change_loudness_deviation_max == 1) { - loudness_norm_param_interface->loudness_deviation_max = - impd_read_bits_buf(it_bit_buff, 6); - if (it_bit_buff->error) return it_bit_buff->error; - } - - loudness_norm_param_interface->change_loudness_measur_method = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_norm_param_interface->change_loudness_measur_method == 1) { - loudness_norm_param_interface->loudness_measurement_method = - impd_read_bits_buf(it_bit_buff, 3); - if (it_bit_buff->error) return it_bit_buff->error; - } - - loudness_norm_param_interface->change_loudness_measur_system = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_norm_param_interface->change_loudness_measur_system == 1) { - loudness_norm_param_interface->loudness_measurement_system = - impd_read_bits_buf(it_bit_buff, 4); - if (it_bit_buff->error) return it_bit_buff->error; - } - - loudness_norm_param_interface->change_loudness_measur_pre_proc = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_norm_param_interface->change_loudness_measur_pre_proc == 1) { - loudness_norm_param_interface->loudness_measurement_pre_proc = - impd_read_bits_buf(it_bit_buff, 2); - if (it_bit_buff->error) return it_bit_buff->error; - } - - loudness_norm_param_interface->change_device_cut_off_freq = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_norm_param_interface->change_device_cut_off_freq == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 6); - if (it_bit_buff->error) return it_bit_buff->error; - loudness_norm_param_interface->device_cut_off_frequency = - max(min(tmp * 10, 500), 20); - } - - loudness_norm_param_interface->change_loudness_norm_gain_db_max = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_norm_param_interface->change_loudness_norm_gain_db_max == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 6); - if (it_bit_buff->error) return it_bit_buff->error; - if (tmp < 63) { - loudness_norm_param_interface->loudness_norm_gain_db_max = tmp * 0.5f; - } else { - loudness_norm_param_interface->loudness_norm_gain_db_max = - LOUDNESS_NORMALIZATION_GAIN_MAX_DEFAULT; - } - } - - loudness_norm_param_interface->change_loudness_norm_gain_modification_db = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_norm_param_interface - ->change_loudness_norm_gain_modification_db == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 10); - if (it_bit_buff->error) return it_bit_buff->error; - loudness_norm_param_interface->loudness_norm_gain_modification_db = - -16 + tmp * 0.03125f; - } - - loudness_norm_param_interface->change_output_peak_level_max = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_norm_param_interface->change_output_peak_level_max == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 6); - if (it_bit_buff->error) return it_bit_buff->error; - loudness_norm_param_interface->output_peak_level_max = tmp * 0.5f; - } - - return (0); -} - -WORD32 impd_drc_interface_read( - ia_bit_buf_struct* it_bit_buff, - ia_dyn_rng_ctrl_interface_struct* drc_ctrl_interface) { - // WORD32 err = 0; - WORD32 i = 0, j = 0, tmp = 0; - - drc_ctrl_interface->dynamic_range_control_on = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - - if (drc_ctrl_interface->dynamic_range_control_on == 1) { - drc_ctrl_interface->num_drc_feature_requests = - impd_read_bits_buf(it_bit_buff, 3); - if (it_bit_buff->error) return it_bit_buff->error; - - for (i = 0; i < drc_ctrl_interface->num_drc_feature_requests; i++) { - drc_ctrl_interface->drc_feature_req_type[i] = - impd_read_bits_buf(it_bit_buff, 2); - if (it_bit_buff->error) return it_bit_buff->error; - - switch (drc_ctrl_interface->drc_feature_req_type[i]) { - case 0: - tmp = impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - - drc_ctrl_interface->requested_num_drc_effects[i] = (tmp >> 4) & 0xf; - drc_ctrl_interface->desired_num_drc_effects_of_requested[i] = - tmp & 0xf; - - for (j = 0; j < drc_ctrl_interface->requested_num_drc_effects[i]; - j++) { - drc_ctrl_interface->requested_drc_effect_type[i][j] = - impd_read_bits_buf(it_bit_buff, 4); - if (it_bit_buff->error) return it_bit_buff->error; - } - break; - case 1: - tmp = impd_read_bits_buf(it_bit_buff, 3); - if (it_bit_buff->error) return it_bit_buff->error; - - drc_ctrl_interface->requested_dyn_rng_measurement_type[i] = - (tmp >> 1) & 3; - drc_ctrl_interface->requested_dyn_range_is_single_val_flag[i] = - tmp & 1; - - if (drc_ctrl_interface->requested_dyn_range_is_single_val_flag[i] == - 0) { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - if (tmp == 0) - drc_ctrl_interface->requested_dyn_range_value[i] = 0.0f; - else if (tmp <= 128) - drc_ctrl_interface->requested_dyn_range_value[i] = tmp * 0.25f; - else if (tmp <= 204) - drc_ctrl_interface->requested_dyn_range_value[i] = - 0.5f * tmp - 32.0f; - else - drc_ctrl_interface->requested_dyn_range_value[i] = tmp - 134.0f; - } else { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - if (tmp == 0) - drc_ctrl_interface->requested_dyn_range_min_val[i] = 0.0f; - else if (tmp <= 128) - drc_ctrl_interface->requested_dyn_range_min_val[i] = tmp * 0.25f; - else if (tmp <= 204) - drc_ctrl_interface->requested_dyn_range_min_val[i] = - 0.5f * tmp - 32.0f; - else - drc_ctrl_interface->requested_dyn_range_min_val[i] = tmp - 134.0f; - tmp = impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - if (tmp == 0) - drc_ctrl_interface->requested_dyn_range_max_val[i] = 0.0f; - else if (tmp <= 128) - drc_ctrl_interface->requested_dyn_range_max_val[i] = tmp * 0.25f; - else if (tmp <= 204) - drc_ctrl_interface->requested_dyn_range_max_val[i] = - 0.5f * tmp - 32.0f; - else - drc_ctrl_interface->requested_dyn_range_max_val[i] = tmp - 134.0f; - } - break; - case 2: - drc_ctrl_interface->requested_drc_characteristic[i] = - impd_read_bits_buf(it_bit_buff, 7); - if (it_bit_buff->error) return it_bit_buff->error; - break; - default: - return (1); - break; - } - } - } - return (0); -} - -WORD32 impd_drc_param_interface_read( - ia_bit_buf_struct* it_bit_buff, - ia_drc_parameter_interface_struct* drc_parameter_interface) { - // WORD32 err = 0; - WORD32 tmp = 0; - - tmp = impd_read_bits_buf(it_bit_buff, 2); - if (it_bit_buff->error) return it_bit_buff->error; - - drc_parameter_interface->change_compress = (tmp >> 1) & 1; - drc_parameter_interface->change_boost = tmp & 1; - - if (drc_parameter_interface->change_compress == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - if (tmp < 255) { - drc_parameter_interface->compress = 1 - tmp * 0.00390625f; - } else { - drc_parameter_interface->compress = 0.f; - } - } - - if (drc_parameter_interface->change_boost == 1) { - tmp = impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - if (tmp < 255) { - drc_parameter_interface->boost = 1 - tmp * 0.00390625f; - } else { - drc_parameter_interface->boost = 0.f; - } - } - - drc_parameter_interface->change_drc_characteristic_target = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - - if (drc_parameter_interface->change_drc_characteristic_target == 1) { - drc_parameter_interface->drc_characteristic_target = - impd_read_bits_buf(it_bit_buff, 8); - if (it_bit_buff->error) return it_bit_buff->error; - } - return (0); -} - -static WORD32 impd_parse_loud_eq_param_interface( - ia_bit_buf_struct* it_bit_buff, ia_loudness_eq_parameter_interface_struct* - loudness_eq_parameter_interface) { - // WORD32 err = 0; - WORD32 bsSensitivity, bsPlaybackGain; - - loudness_eq_parameter_interface->loudness_eq_request_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_eq_parameter_interface->loudness_eq_request_flag) { - loudness_eq_parameter_interface->loudness_eq_request = - impd_read_bits_buf(it_bit_buff, 2); - if (it_bit_buff->error) return it_bit_buff->error; - } - loudness_eq_parameter_interface->sensitivity_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_eq_parameter_interface->sensitivity_flag) { - bsSensitivity = impd_read_bits_buf(it_bit_buff, 7); - if (it_bit_buff->error) return it_bit_buff->error; - loudness_eq_parameter_interface->sensitivity = bsSensitivity + 23.0f; - } - loudness_eq_parameter_interface->playback_gain_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (loudness_eq_parameter_interface->playback_gain_flag) { - bsPlaybackGain = impd_read_bits_buf(it_bit_buff, 7); - if (it_bit_buff->error) return it_bit_buff->error; - loudness_eq_parameter_interface->playback_gain = (FLOAT32)-bsPlaybackGain; - } - return (0); -} - -WORD32 -impd_unidrc_interface_extension_read( - ia_bit_buf_struct* it_bit_buff, - ia_drc_interface_struct* impd_drc_uni_interface, - ia_drc_uni_interface_ext_struct* drc_uni_interface_ext) { - WORD32 err = 0, i = 0, tmp = 0, dummy; - WORD32 uni_drc_interface_ext_type; - ia_specific_interface_extension_struct* specific_interface_ext; - - uni_drc_interface_ext_type = impd_read_bits_buf(it_bit_buff, 4); - if (it_bit_buff->error) return it_bit_buff->error; - - while (uni_drc_interface_ext_type != UNIDRCINTERFACEEXT_TERM) { - specific_interface_ext = - &(drc_uni_interface_ext->specific_interface_ext[i]); - specific_interface_ext->uni_drc_interface_ext_type = - uni_drc_interface_ext_type; - tmp = impd_read_bits_buf(it_bit_buff, 4); - if (it_bit_buff->error) return it_bit_buff->error; - specific_interface_ext->ext_size_bits = tmp + 4; - - tmp = - impd_read_bits_buf(it_bit_buff, specific_interface_ext->ext_size_bits); - if (it_bit_buff->error) return it_bit_buff->error; - - specific_interface_ext->ext_bit_size = tmp + 1; - - switch (uni_drc_interface_ext_type) { - case UNIDRCINTERFACEEXT_EQ: - impd_drc_uni_interface->drc_uni_interface_ext - .loudness_eq_parameter_interface_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (impd_drc_uni_interface->drc_uni_interface_ext - .loudness_eq_parameter_interface_flag) { - err = impd_parse_loud_eq_param_interface( - it_bit_buff, &(impd_drc_uni_interface->drc_uni_interface_ext - .loudness_eq_parameter_interface)); - if (err) return (err); - } - impd_drc_uni_interface->drc_uni_interface_ext.eq_ctrl_interface_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (impd_drc_uni_interface->drc_uni_interface_ext - .eq_ctrl_interface_flag) { - impd_drc_uni_interface->drc_uni_interface_ext.eq_ctrl_interface - .eq_set_purpose_request = impd_read_bits_buf(it_bit_buff, 16); - if (it_bit_buff->error) return it_bit_buff->error; - } - break; - default: - dummy = impd_read_bits_buf(it_bit_buff, - specific_interface_ext->ext_bit_size); - if (it_bit_buff->error) return it_bit_buff->error; - break; - } - - i++; - if (i == EXT_COUNT_MAX) { - return (1); - } - uni_drc_interface_ext_type = impd_read_bits_buf(it_bit_buff, 4); - if (it_bit_buff->error) return it_bit_buff->error; - } - drc_uni_interface_ext->interface_ext_count = i; - return (0); -} -WORD32 impd_unidrc_interface_read(ia_bit_buf_struct* it_bit_buff, - ia_drc_interface_struct* uniDrcInterface) { - WORD32 err = 0; - - uniDrcInterface->interface_signat_flag = impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (uniDrcInterface->interface_signat_flag == 1) { - err = impd_unidrc_interface_signature_read( - it_bit_buff, &(uniDrcInterface->drc_uni_interface_signature)); - if (err) return (err); - } - - uniDrcInterface->system_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (uniDrcInterface->system_interface_flag == 1) { - err = impd_sys_interface_read(it_bit_buff, - &(uniDrcInterface->system_interface)); - if (err) return (err); - } - - uniDrcInterface->loudness_norm_ctrl_interface_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (uniDrcInterface->loudness_norm_ctrl_interface_flag == 1) { - err = impd_loudness_norm_control_interface_read( - it_bit_buff, &(uniDrcInterface->loudness_norm_ctrl_interface)); - if (err) return (err); - } - - uniDrcInterface->loudness_norm_parameter_interface_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (uniDrcInterface->loudness_norm_parameter_interface_flag == 1) { - err = impd_loudness_norm_param_interface_read( - it_bit_buff, &(uniDrcInterface->loudness_norm_param_interface)); - if (err) return (err); - } - - uniDrcInterface->drc_interface_flag = impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (uniDrcInterface->drc_interface_flag == 1) { - err = impd_drc_interface_read(it_bit_buff, - &(uniDrcInterface->drc_ctrl_interface)); - if (err) return (err); - } - - uniDrcInterface->drc_parameter_interface_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (uniDrcInterface->drc_parameter_interface_flag == 1) { - err = impd_drc_param_interface_read( - it_bit_buff, &(uniDrcInterface->drc_parameter_interface)); - if (err) return (err); - } - - uniDrcInterface->drc_uni_interface_ext_flag = - impd_read_bits_buf(it_bit_buff, 1); - if (it_bit_buff->error) return it_bit_buff->error; - if (uniDrcInterface->drc_uni_interface_ext_flag == 1) { - err = impd_unidrc_interface_extension_read( - it_bit_buff, uniDrcInterface, - &(uniDrcInterface->drc_uni_interface_ext)); - if (err) return (err); - } - - return (0); -}
\ No newline at end of file diff --git a/decoder/drc_src/impd_drc_loud_eq.c b/decoder/drc_src/impd_drc_loud_eq.c deleted file mode 100644 index ef04db2..0000000 --- a/decoder/drc_src/impd_drc_loud_eq.c +++ /dev/null @@ -1,169 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2015 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 <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <string.h> -#include "impd_type_def.h" -#include "impd_drc_uni_tables.h" -#include "impd_drc_uni_common.h" -#include "impd_drc_uni_interface.h" -#include "impd_drc_struct.h" -#include "impd_drc_uni_gain_dec.h" -#include "impd_drc_uni_loud_eq.h" -#include "impd_parametric_drc_dec.h" -#include "impd_drc_uni_multi_band.h" -#include "impd_drc_filter_bank.h" -#include "impd_drc_uni_process_audio.h" -#include "impd_drc_rom.h" - -WORD32 impd_parametric_drc_instance_reset( - WORD32 instance_idx, ia_parametric_drc_instance_params_struct* - pstr_parametric_drc_instance_params) { - WORD32 err = 0; - - if (pstr_parametric_drc_instance_params->parametric_drc_type == - PARAM_DRC_TYPE_FF) { - ia_parametric_drc_type_ff_params_struct* - pstr_parametric_ffwd_type_drc_params = - &(pstr_parametric_drc_instance_params - ->str_parametric_drc_type_ff_params); - err = impd_parametric_ffwd_type_drc_reset( - pstr_parametric_ffwd_type_drc_params); - if (err) return (err); - - } else { - return (UNEXPECTED_ERROR); - } - - return 0; -} - -WORD32 impd_add_drc_band_audio( - ia_drc_instructions_struct* pstr_drc_instruction_arr, - const WORD32 drc_instructions_index, - ia_drc_params_struct* ia_drc_params_struct, - ia_audio_band_buffer_struct* audio_band_buffer, FLOAT32* audio_io_buf[]) { - WORD32 g, b, i, c; - FLOAT32 sum; - WORD32 signalIndex = 0; - FLOAT32** drcBandAudio; - FLOAT32** channel_audio; - ia_drc_instructions_struct* str_drc_instruction_str; - - drcBandAudio = audio_band_buffer->non_interleaved_audio; - channel_audio = audio_io_buf; - - if (drc_instructions_index >= 0) { - str_drc_instruction_str = - &(pstr_drc_instruction_arr[drc_instructions_index]); - } else { - return -1; - } - - if (str_drc_instruction_str->drc_set_id > 0) { - for (c = 0; c < str_drc_instruction_str->audio_num_chan; c++) - - { - g = str_drc_instruction_str->channel_group_of_ch[c]; - if (g >= 0) { - for (i = 0; i < ia_drc_params_struct->drc_frame_size; i++) { - sum = 0.0f; - for (b = 0; b < str_drc_instruction_str->band_count_of_ch_group[g]; - b++) { - sum += drcBandAudio[signalIndex + b][i]; - } - - channel_audio[c][i] = sum; - } - signalIndex += str_drc_instruction_str->band_count_of_ch_group[g]; - } else { - signalIndex++; - } - } - } else { - for (c = 0; c < str_drc_instruction_str->audio_num_chan; c++) - - { - for (i = 0; i < ia_drc_params_struct->drc_frame_size; i++) { - channel_audio[c][i] = drcBandAudio[c][i]; - } - } - } - return (0); -} - -WORD32 removeTables(void) { return (0); } - -const ia_slope_code_table_struct* impd_get_slope_code_tbl_by_value(void) { - return (&(slopeCodeTableEntryByValue[0])); -} - -FLOAT32 impd_decode_slope_idx(const WORD32 slopeCodeIndex) { - const ia_slope_code_table_struct* slopeCodeTable = - impd_get_slope_code_tbl_by_value(); - return slopeCodeTable[slopeCodeIndex].value; -} - -FLOAT32 impd_decode_slope_idx_magnitude(const WORD32 slopeCodeIndex) { - const ia_slope_code_table_struct* slopeCodeTable = - impd_get_slope_code_tbl_by_value(); - return (FLOAT32)fabs((FLOAT64)slopeCodeTable[slopeCodeIndex].value); -} - -WORD32 impd_get_multi_band_drc_present(ia_drc_config* pstr_drc_config, - WORD32 numSets[3], - WORD32 multiBandDrcPresent[3]) { - WORD32 err = 0, k, m; - for (k = 0; k < pstr_drc_config->drc_instructions_uni_drc_count; k++) { - if ((pstr_drc_config->str_drc_instruction_str[k].downmix_id[0] == - ID_FOR_BASE_LAYOUT) || - (pstr_drc_config->str_drc_instruction_str[k].drc_apply_to_dwnmix == - 0)) { - numSets[0]++; - } else if (pstr_drc_config->str_drc_instruction_str[k].downmix_id[0] == - ID_FOR_ANY_DOWNMIX) { - numSets[1]++; - } else { - numSets[2]++; - } - for (m = 0; - m < pstr_drc_config->str_drc_instruction_str[k].num_drc_ch_groups; - m++) { - if (pstr_drc_config->str_p_loc_drc_coefficients_uni_drc[0] - .gain_set_params[pstr_drc_config->str_drc_instruction_str - ->gain_set_index_for_channel_group[m]] - .band_count > 1) { - if ((pstr_drc_config->str_drc_instruction_str[k].downmix_id[0] == - ID_FOR_BASE_LAYOUT) || - (pstr_drc_config->str_drc_instruction_str[k].drc_apply_to_dwnmix == - 0)) { - multiBandDrcPresent[0] = 1; - } else if (pstr_drc_config->str_drc_instruction_str[k].downmix_id[0] == - ID_FOR_ANY_DOWNMIX) { - multiBandDrcPresent[1] = 1; - } else { - multiBandDrcPresent[2] = 1; - } - } - } - } - return err; -} diff --git a/decoder/drc_src/impd_drc_loudness_control.c b/decoder/drc_src/impd_drc_loudness_control.c index 9937e18..eee37d3 100644 --- a/decoder/drc_src/impd_drc_loudness_control.c +++ b/decoder/drc_src/impd_drc_loudness_control.c @@ -737,7 +737,7 @@ WORD32 impd_init_loudness_control( WORD32 requested_measurement_system = MEASUREMENT_SYSTEM_BS_1770_4; WORD32 requested_preprocessing = 0; - WORD32* system_bonus = measurement_system_default_tbl; + const WORD32* system_bonus = measurement_system_default_tbl; WORD32 match_measure; FLOAT32 method_val = 0; diff --git a/decoder/drc_src/impd_drc_main_qmf_process.c b/decoder/drc_src/impd_drc_main_qmf_process.c deleted file mode 100644 index 3c4e711..0000000 --- a/decoder/drc_src/impd_drc_main_qmf_process.c +++ /dev/null @@ -1,254 +0,0 @@ -/****************************************************************************** - * - * 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 <math.h> -#include "impd_type_def.h" -#include "impd_memory_standards.h" -#include "impd_drc_bitbuffer.h" -#include "impd_drc_extr_delta_coded_info.h" -#include "impd_drc_common.h" -#include "impd_drc_struct.h" -#include "impd_drc_interface.h" - -#include "impd_drc_bitstream_dec_api.h" -#include "impd_drc_gain_dec.h" -#include "impd_drc_filter_bank.h" -#include "impd_drc_multi_band.h" -#include "impd_drc_process_audio.h" -#include "impd_parametric_drc_dec.h" -#include "impd_drc_eq.h" -#include "impd_drc_gain_decoder.h" -#include "impd_drc_selection_process.h" - -#include "impd_drc_peak_limiter.h" -#include "impd_drc_api_struct_def.h" - -#define BITSTREAM_FILE_FORMAT_SPLIT 1 - -static WORD32 impd_down_mix( - ia_drc_sel_proc_output_struct *uni_drc_sel_proc_output, - FLOAT32 **input_audio, WORD32 frame_len) { - WORD32 num_base_ch = uni_drc_sel_proc_output->base_channel_count; - WORD32 num_target_ch = uni_drc_sel_proc_output->target_channel_count; - WORD32 i, i_ch, o_ch; - FLOAT32 tmp_out[MAX_CHANNEL_COUNT]; - - if (uni_drc_sel_proc_output->downmix_matrix_present == 0) return 0; - - if (input_audio == 0) return 0; - - if (num_target_ch > MAX_CHANNEL_COUNT) return -1; - - if (num_target_ch > num_base_ch) return -1; - - for (i = 0; i < frame_len; i++) { - for (o_ch = 0; o_ch < num_target_ch; o_ch++) { - tmp_out[o_ch] = 0.0f; - for (i_ch = 0; i_ch < num_base_ch; i_ch++) { - tmp_out[o_ch] += input_audio[i_ch][i] * - uni_drc_sel_proc_output->downmix_matrix[i_ch][o_ch]; - } - } - for (o_ch = 0; o_ch < num_target_ch; o_ch++) { - input_audio[o_ch][i] = tmp_out[o_ch]; - } - for (; o_ch < num_base_ch; o_ch++) { - input_audio[o_ch][i] = 0.0f; - } - } - - return 0; -} - -WORD32 impd_init_process_audio_main_qmf(ia_drc_api_struct *p_obj_drc) - -{ - WORD32 error = 0, i, j, num_samples_per_channel; - FLOAT32 *input_buffer; - FLOAT32 *output_buffer; - FLOAT32 *audio_io_buf_real[10]; - FLOAT32 *audio_io_buf_imag[10]; - FLOAT32 *scratch_buffer; - WORD32 last_frame = 0; - scratch_buffer = (FLOAT32 *)p_obj_drc->pp_mem[1]; - input_buffer = (FLOAT32 *)p_obj_drc->pp_mem[2]; - output_buffer = (FLOAT32 *)p_obj_drc->pp_mem[3]; - - if (p_obj_drc->p_state->ui_in_bytes <= 0) { - p_obj_drc->p_state->ui_out_bytes = 0; - return 0; - } - - if ((p_obj_drc->p_state->ui_in_bytes / p_obj_drc->str_config.num_ch_in / - (p_obj_drc->str_config.pcm_size >> 3)) < - (UWORD32)p_obj_drc->str_config.frame_size) - last_frame = 1; - for (i = 0; i < p_obj_drc->str_config.num_ch_in; i++) { - audio_io_buf_real[i] = - scratch_buffer + i * (p_obj_drc->str_config.frame_size + 32); - audio_io_buf_imag[i] = - scratch_buffer + - p_obj_drc->str_config.num_ch_in * p_obj_drc->str_config.frame_size + - p_obj_drc->str_config.num_ch_in * 64 + - i * (p_obj_drc->str_config.frame_size + 64); - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - audio_io_buf_real[i][j] = - input_buffer[j * p_obj_drc->str_config.num_ch_in + i]; - audio_io_buf_imag[i][j] = - input_buffer[p_obj_drc->str_config.num_ch_in * - p_obj_drc->str_config.frame_size + - j * p_obj_drc->str_config.num_ch_in + i]; - } - } - - error = impd_process_drc_bitstream_dec_gain( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - if (p_obj_drc->str_bit_handler.gain_stream_flag == - 0) // ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - - if (p_obj_drc->str_config.bitstream_file_format == - BITSTREAM_FILE_FORMAT_SPLIT) { - if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { - p_obj_drc->str_bit_handler.num_bits_read_bs = - p_obj_drc->str_bit_handler.num_bits_read_bs + 8 - - p_obj_drc->str_bit_handler.num_bits_offset_bs; - p_obj_drc->str_bit_handler.num_bytes_read_bs = - p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; - p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; - p_obj_drc->str_bit_handler.byte_index_bs = - p_obj_drc->str_bit_handler.byte_index_bs + 1; - if (p_obj_drc->str_bit_handler.gain_stream_flag == - 0) // ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs = - p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } - } - } - - error = impd_drc_process_freq_domain( - p_obj_drc->str_payload.pstr_gain_dec[0], - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, audio_io_buf_real, - audio_io_buf_imag, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, - p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->drc_characteristic_target); - if (error) return -1; - - error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, - audio_io_buf_real, p_obj_drc->str_config.frame_size); - if (error) return -1; - - error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, - audio_io_buf_imag, p_obj_drc->str_config.frame_size); - if (error) return -1; - - error = impd_drc_process_freq_domain( - p_obj_drc->str_payload.pstr_gain_dec[1], - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, audio_io_buf_real, - audio_io_buf_imag, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, - p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->drc_characteristic_target); - if (error) return -1; - - if (p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db != 0.0f) { - FLOAT32 loudness_normalization_gain = - (FLOAT32)pow(10.0, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db / - 20.0); - for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - audio_io_buf_real[i][j] *= loudness_normalization_gain; - audio_io_buf_imag[i][j] *= loudness_normalization_gain; - } - } - } - num_samples_per_channel = p_obj_drc->str_config.frame_size; - - for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - output_buffer[j * p_obj_drc->str_config.num_ch_out + i] = - audio_io_buf_real[i][j]; - output_buffer[p_obj_drc->str_config.frame_size * - p_obj_drc->str_config.num_ch_in + - j * p_obj_drc->str_config.num_ch_out + i] = - audio_io_buf_imag[i][j]; - } - } - p_obj_drc->p_state->ui_out_bytes = - p_obj_drc->str_config.num_ch_out * (p_obj_drc->str_config.frame_size) * 4; - p_obj_drc->p_state->ui_out_bytes = - p_obj_drc->str_config.num_ch_out * - (p_obj_drc->p_state->ui_in_bytes / p_obj_drc->str_config.num_ch_in); - - if (last_frame == 0) { - if (p_obj_drc->str_config.bitstream_file_format != - BITSTREAM_FILE_FORMAT_SPLIT) { - error = impd_process_drc_bitstream_dec( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_loudness_info, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - } - return error; -} diff --git a/decoder/drc_src/impd_drc_main_stft_process.c b/decoder/drc_src/impd_drc_main_stft_process.c deleted file mode 100644 index c1e89e1..0000000 --- a/decoder/drc_src/impd_drc_main_stft_process.c +++ /dev/null @@ -1,254 +0,0 @@ -/****************************************************************************** - * - * 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 <math.h> -#include "impd_type_def.h" -#include "impd_memory_standards.h" -#include "impd_drc_bitbuffer.h" -#include "impd_drc_extr_delta_coded_info.h" -#include "impd_drc_common.h" -#include "impd_drc_struct.h" -#include "impd_drc_interface.h" -#include "impd_drc_peak_limiter.h" -#include "impd_drc_bitstream_dec_api.h" -#include "impd_drc_gain_dec.h" -#include "impd_drc_filter_bank.h" -#include "impd_drc_multi_band.h" -#include "impd_drc_process_audio.h" -#include "impd_parametric_drc_dec.h" -#include "impd_drc_eq.h" -#include "impd_drc_gain_decoder.h" -#include "impd_drc_selection_process.h" -#include "impd_drc_api_struct_def.h" - -#define BITSTREAM_FILE_FORMAT_SPLIT 1 - -static WORD32 impd_down_mix( - ia_drc_sel_proc_output_struct *uni_drc_sel_proc_output, - FLOAT32 **input_audio, WORD32 frame_len) { - WORD32 num_base_ch = uni_drc_sel_proc_output->base_channel_count; - WORD32 num_target_ch = uni_drc_sel_proc_output->target_channel_count; - WORD32 i, i_ch, o_ch; - FLOAT32 tmp_out[MAX_CHANNEL_COUNT]; - - if (uni_drc_sel_proc_output->downmix_matrix_present == 0) return 0; - - if (input_audio == 0) return 0; - - if (num_target_ch > MAX_CHANNEL_COUNT) return -1; - - if (num_target_ch > num_base_ch) return -1; - - for (i = 0; i < frame_len; i++) { - for (o_ch = 0; o_ch < num_target_ch; o_ch++) { - tmp_out[o_ch] = 0.0f; - for (i_ch = 0; i_ch < num_base_ch; i_ch++) { - tmp_out[o_ch] += input_audio[i_ch][i] * - uni_drc_sel_proc_output->downmix_matrix[i_ch][o_ch]; - } - } - for (o_ch = 0; o_ch < num_target_ch; o_ch++) { - input_audio[o_ch][i] = tmp_out[o_ch]; - } - for (; o_ch < num_base_ch; o_ch++) { - input_audio[o_ch][i] = 0.0f; - } - } - - return 0; -} - -WORD32 impd_init_process_audio_main_stft(ia_drc_api_struct *p_obj_drc) - -{ - WORD32 error = 0, i, j, num_samples_per_channel; - FLOAT32 *input_buffer; - FLOAT32 *output_buffer; - FLOAT32 *audio_io_buf_real[10]; - FLOAT32 *audio_io_buf_imag[10]; - FLOAT32 *scratch_buffer; - WORD32 last_frame = 0; - scratch_buffer = (FLOAT32 *)p_obj_drc->pp_mem[1]; - input_buffer = (FLOAT32 *)p_obj_drc->pp_mem[2]; - output_buffer = (FLOAT32 *)p_obj_drc->pp_mem[3]; - - if (p_obj_drc->p_state->ui_in_bytes <= 0) { - p_obj_drc->p_state->ui_out_bytes = 0; - return 0; - } - - if ((p_obj_drc->p_state->ui_in_bytes / p_obj_drc->str_config.num_ch_in / - (p_obj_drc->str_config.pcm_size >> 3)) < - (UWORD32)p_obj_drc->str_config.frame_size) - last_frame = 1; - for (i = 0; i < p_obj_drc->str_config.num_ch_in; i++) { - audio_io_buf_real[i] = - scratch_buffer + i * (p_obj_drc->str_config.frame_size + 32); - audio_io_buf_imag[i] = - scratch_buffer + - p_obj_drc->str_config.num_ch_in * p_obj_drc->str_config.frame_size + - p_obj_drc->str_config.num_ch_in * 64 + - i * (p_obj_drc->str_config.frame_size + 64); - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - audio_io_buf_real[i][j] = - input_buffer[j * p_obj_drc->str_config.num_ch_in + i]; - audio_io_buf_imag[i][j] = - input_buffer[p_obj_drc->str_config.num_ch_in * - p_obj_drc->str_config.frame_size + - j * p_obj_drc->str_config.num_ch_in + i]; - } - } - - error = impd_process_drc_bitstream_dec_gain( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - if (p_obj_drc->str_bit_handler.gain_stream_flag == - 0) // ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - - if (p_obj_drc->str_config.bitstream_file_format == - BITSTREAM_FILE_FORMAT_SPLIT) { - if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { - p_obj_drc->str_bit_handler.num_bits_read_bs = - p_obj_drc->str_bit_handler.num_bits_read_bs + 8 - - p_obj_drc->str_bit_handler.num_bits_offset_bs; - p_obj_drc->str_bit_handler.num_bytes_read_bs = - p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; - p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; - p_obj_drc->str_bit_handler.byte_index_bs = - p_obj_drc->str_bit_handler.byte_index_bs + 1; - if (p_obj_drc->str_bit_handler.gain_stream_flag == - 0) // ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs = - p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } - } - } - - error = impd_drc_process_freq_domain( - p_obj_drc->str_payload.pstr_gain_dec[0], - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, audio_io_buf_real, - audio_io_buf_imag, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, - p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->drc_characteristic_target); - if (error) return -1; - - error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, - audio_io_buf_real, p_obj_drc->str_config.frame_size); - if (error) return -1; - - error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, - audio_io_buf_imag, p_obj_drc->str_config.frame_size); - if (error) return -1; - - error = impd_drc_process_freq_domain( - p_obj_drc->str_payload.pstr_gain_dec[1], - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, audio_io_buf_real, - audio_io_buf_imag, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, - p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->drc_characteristic_target); - if (error) return -1; - - if (p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db != 0.0f) { - FLOAT32 loudness_normalization_gain = - (FLOAT32)pow(10.0, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db / - 20.0); - for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - audio_io_buf_real[i][j] *= loudness_normalization_gain; - audio_io_buf_imag[i][j] *= loudness_normalization_gain; - } - } - } - - num_samples_per_channel = p_obj_drc->str_config.frame_size; - - for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - output_buffer[j * p_obj_drc->str_config.num_ch_out + i] = - audio_io_buf_real[i][j]; - output_buffer[p_obj_drc->str_config.frame_size * - p_obj_drc->str_config.num_ch_in + - j * p_obj_drc->str_config.num_ch_out + i] = - audio_io_buf_imag[i][j]; - } - } - p_obj_drc->p_state->ui_out_bytes = - p_obj_drc->str_config.num_ch_out * (p_obj_drc->str_config.frame_size) * 4; - p_obj_drc->p_state->ui_out_bytes = - p_obj_drc->str_config.num_ch_out * - (p_obj_drc->p_state->ui_in_bytes / p_obj_drc->str_config.num_ch_in); - - if (last_frame == 0) { - if (p_obj_drc->str_config.bitstream_file_format != - BITSTREAM_FILE_FORMAT_SPLIT) { - error = impd_process_drc_bitstream_dec( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_loudness_info, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - } - - return error; -} diff --git a/decoder/drc_src/impd_drc_main_td_process.c b/decoder/drc_src/impd_drc_main_td_process.c index 6449531..ccd190e 100644 --- a/decoder/drc_src/impd_drc_main_td_process.c +++ b/decoder/drc_src/impd_drc_main_td_process.c @@ -75,18 +75,9 @@ static IA_ERRORCODE impd_down_mix( IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { IA_ERRORCODE err_code = IA_NO_ERROR; WORD32 i, j; - FLOAT32 *input_buffer; - WORD16 *input_buffer16, *output_buffer16; - FLOAT32 *output_buffer; FLOAT32 *audio_buff[10]; - FLOAT32 *scratch_buffer; WORD32 last_frame = 0; WORD32 num_sample_to_process; - scratch_buffer = (FLOAT32 *)p_obj_drc->pp_mem[1]; - input_buffer = (FLOAT32 *)p_obj_drc->pp_mem[2]; - output_buffer = (FLOAT32 *)p_obj_drc->pp_mem[3]; - input_buffer16 = (WORD16 *)p_obj_drc->pp_mem[2]; - output_buffer16 = (WORD16 *)p_obj_drc->pp_mem[3]; if (p_obj_drc->p_state->ui_in_bytes <= 0) { p_obj_drc->p_state->ui_out_bytes = 0; @@ -111,29 +102,16 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); p_obj_drc->str_bit_handler.byte_index_bs += p_obj_drc->str_bit_handler.num_bytes_read_bs; - if (p_obj_drc->str_bit_handler.gain_stream_flag == - 0) // ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - if (p_obj_drc->str_config.bitstream_file_format == - BITSTREAM_FILE_FORMAT_SPLIT) { - if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { - p_obj_drc->str_bit_handler.num_bits_read_bs = - p_obj_drc->str_bit_handler.num_bits_read_bs + 8 - - p_obj_drc->str_bit_handler.num_bits_offset_bs; - p_obj_drc->str_bit_handler.num_bytes_read_bs = - p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; - p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; - p_obj_drc->str_bit_handler.byte_index_bs = - p_obj_drc->str_bit_handler.byte_index_bs + 1; - if (p_obj_drc->str_bit_handler.gain_stream_flag == 0) { - p_obj_drc->str_bit_handler.num_bytes_bs = - p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } - } + if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { + p_obj_drc->str_bit_handler.num_bits_read_bs = + p_obj_drc->str_bit_handler.num_bits_read_bs + 8 - + p_obj_drc->str_bit_handler.num_bits_offset_bs; + p_obj_drc->str_bit_handler.num_bytes_read_bs = + p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; + p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; + p_obj_drc->str_bit_handler.byte_index_bs = + p_obj_drc->str_bit_handler.byte_index_bs + 1; } num_sample_to_process = @@ -145,6 +123,8 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { if (num_sample_to_process < p_obj_drc->str_config.frame_size) last_frame = 1; if (p_obj_drc->str_config.pcm_size == 16) { + FLOAT32 *scratch_buffer = (FLOAT32 *)p_obj_drc->pp_mem[1]; + WORD16 *input_buffer16 = (WORD16 *)p_obj_drc->pp_mem[2]; for (i = 0; i < p_obj_drc->str_config.num_ch_in; i++) { audio_buff[i] = scratch_buffer + i * (p_obj_drc->str_config.frame_size + 32); @@ -155,7 +135,29 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { 32767.0f; } } + } else if (p_obj_drc->str_config.pcm_size == 24) { + FLOAT32 *scratch_buffer = (FLOAT32 *)p_obj_drc->pp_mem[1]; + WORD8 *input_buffer8 = (WORD8 *)p_obj_drc->pp_mem[2]; + for (i = 0; i < p_obj_drc->str_config.num_ch_in; i++) { + audio_buff[i] = + scratch_buffer + i * (p_obj_drc->str_config.frame_size + 32); + + for (j = 0; j < num_sample_to_process; j++) { + WORD32 temp; + + WORD8 *addr = + (WORD8 *)(&input_buffer8[3 * j * p_obj_drc->str_config.num_ch_in + + 3 * i]); + temp = (WORD8)(*(addr + 2)); + temp = (temp << 8) | ((WORD8)(*(addr + 1)) & 0xff); + temp = (temp << 8) | (((WORD8) * (addr)) & 0xff); + + audio_buff[i][j] = (FLOAT32)((temp) / 8388607.0f); + } + } } else { + FLOAT32 *scratch_buffer = (FLOAT32 *)p_obj_drc->pp_mem[1]; + FLOAT32 *input_buffer = (FLOAT32 *)p_obj_drc->pp_mem[2]; for (i = 0; i < p_obj_drc->str_config.num_ch_in; i++) { audio_buff[i] = scratch_buffer + i * (p_obj_drc->str_config.frame_size + 32); @@ -214,6 +216,7 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { } if (p_obj_drc->str_config.peak_limiter) { + FLOAT32 *output_buffer = (FLOAT32 *)p_obj_drc->pp_mem[3]; for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { output_buffer[j * p_obj_drc->str_config.num_ch_out + i] = @@ -236,6 +239,7 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { } if (p_obj_drc->str_config.pcm_size == 16) { + WORD16 *output_buffer16 = (WORD16 *)p_obj_drc->pp_mem[3]; for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { if (audio_buff[i][j] < -1.0f) @@ -249,7 +253,30 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { (WORD16)(audio_buff[i][j] * 32767.0f); } } + } else if (p_obj_drc->str_config.pcm_size == 24) { + WORD8 *output_buffer8 = (WORD8 *)p_obj_drc->pp_mem[3]; + for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { + for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { + WORD32 temp = 0; + WORD8 *temp_addr = + &output_buffer8[3 * j * p_obj_drc->str_config.num_ch_out + 3 * i]; + + if (audio_buff[i][j] < -1.0f) + temp = -8388607; + + else if (audio_buff[i][j] > 1.0f) + temp = 8388607; + + else + temp = (WORD32)(audio_buff[i][j] * 8388607.0f); + + *temp_addr++ = (WORD8)(temp & 0xff); + *temp_addr++ = (WORD8)((WORD32)temp >> 8) & 0xff; + *temp_addr = (WORD8)((WORD32)temp >> 16) & 0xff; + } + } } else { + FLOAT32 *output_buffer = (FLOAT32 *)p_obj_drc->pp_mem[3]; for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { output_buffer[j * p_obj_drc->str_config.num_ch_out + i] = @@ -263,6 +290,8 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { (p_obj_drc->p_state->ui_in_bytes / p_obj_drc->str_config.num_ch_in); if (p_obj_drc->p_state->delay_in_output != 0) { + FLOAT32 *output_buffer = (FLOAT32 *)p_obj_drc->pp_mem[3]; + WORD16 *output_buffer16 = (WORD16 *)p_obj_drc->pp_mem[3]; p_obj_drc->p_state->ui_out_bytes = p_obj_drc->str_config.num_ch_out * (p_obj_drc->str_config.frame_size - p_obj_drc->p_state->delay_in_output) * @@ -294,32 +323,5 @@ IA_ERRORCODE impd_process_time_domain(ia_drc_api_struct *p_obj_drc) { p_obj_drc->str_config.num_ch_out * (p_obj_drc->str_config.pcm_size >> 3); } - - if (last_frame == 0) { - if (p_obj_drc->str_config.bitstream_file_format != - BITSTREAM_FILE_FORMAT_SPLIT) { - err_code = impd_process_drc_bitstream_dec( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_loudness_info, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (err_code > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - } - return err_code; } diff --git a/decoder/drc_src/impd_drc_main_td_qmf_process.c b/decoder/drc_src/impd_drc_main_td_qmf_process.c deleted file mode 100644 index 2697c54..0000000 --- a/decoder/drc_src/impd_drc_main_td_qmf_process.c +++ /dev/null @@ -1,364 +0,0 @@ -/****************************************************************************** - * - * 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 <math.h> -#include "impd_type_def.h" -#include "impd_memory_standards.h" -#include "impd_drc_peak_limiter.h" -#include "impd_drc_extr_delta_coded_info.h" -#include "impd_drc_common.h" -#include "impd_drc_struct.h" -#include "impd_drc_interface.h" -#include "impd_drc_bitbuffer.h" -#include "impd_drc_bitstream_dec_api.h" -#include "impd_drc_gain_dec.h" -#include "impd_drc_filter_bank.h" -#include "impd_drc_multi_band.h" -#include "impd_drc_process_audio.h" -#include "impd_parametric_drc_dec.h" -#include "impd_drc_eq.h" -#include "impd_drc_gain_decoder.h" -#include "impd_drc_selection_process.h" -#include "impd_drc_api_struct_def.h" -#include "impd_drc_hashdefines.h" -#include "impd_drc_rom.h" - -VOID process_qmf_syn_filt_bank(ia_drc_qmf_filt_struct *qmf_filt, FLOAT64 *buff, - FLOAT32 *input_real, FLOAT32 *input_imag, - FLOAT32 *output) { - WORD32 i, j; - FLOAT64 U[10 * QMF_NUM_FILT_BANDS]; - FLOAT64 W[10 * QMF_NUM_FILT_BANDS]; - - FLOAT64 tmp; - - for (i = 20 * QMF_FILT_RESOLUTION - 1; i >= 2 * QMF_FILT_RESOLUTION; i--) { - buff[i] = buff[i - 2 * QMF_FILT_RESOLUTION]; - } - - for (i = 0; i < 2 * QMF_FILT_RESOLUTION; i++) { - tmp = 0.0; - for (j = 0; j < QMF_FILT_RESOLUTION; j++) { - tmp = tmp + input_real[j] * qmf_filt->syn_tab_real[i][j] - - input_imag[j] * qmf_filt->syn_tab_imag[i][j]; - } - buff[i] = tmp; - } - - for (i = 0; i < 5; i++) { - for (j = 0; j < QMF_FILT_RESOLUTION; j++) { - U[2 * QMF_FILT_RESOLUTION * i + j] = - buff[4 * QMF_FILT_RESOLUTION * i + j]; - U[2 * QMF_FILT_RESOLUTION * i + QMF_FILT_RESOLUTION + j] = - buff[4 * QMF_FILT_RESOLUTION * i + 3 * QMF_FILT_RESOLUTION + j]; - } - } - - for (i = 0; i < 10 * QMF_FILT_RESOLUTION; i++) { - W[i] = U[i] * qmf_filter_coeff[i]; - } - - for (i = 0; i < QMF_FILT_RESOLUTION; i++) { - tmp = 0.0; - for (j = 0; j < 10; j++) { - tmp = tmp + W[QMF_FILT_RESOLUTION * j + i]; - } - output[i] = (FLOAT32)tmp; - } -} - -VOID process_qmf_ana_filt_bank(ia_drc_qmf_filt_struct *qmf_filt, FLOAT64 *buff, - FLOAT32 *input, FLOAT32 *output_real, - FLOAT32 *output_imag) { - WORD32 i, j; - FLOAT32 Z[10 * QMF_NUM_FILT_BANDS]; - FLOAT32 Y[2 * QMF_NUM_FILT_BANDS]; - - for (i = 10 * QMF_FILT_RESOLUTION - 1; i >= QMF_FILT_RESOLUTION; i--) { - buff[i] = buff[i - QMF_FILT_RESOLUTION]; - } - - for (i = QMF_FILT_RESOLUTION - 1; i >= 0; i--) { - buff[i] = input[QMF_FILT_RESOLUTION - 1 - i]; - } - - for (i = 0; i < 10 * QMF_FILT_RESOLUTION; i++) { - Z[i] = (FLOAT32)(buff[i] * qmf_filter_coeff[i]); - } - - for (i = 0; i < 2 * QMF_FILT_RESOLUTION; i++) { - Y[i] = 0.0f; - for (j = 0; j < 5; j++) { - Y[i] += Z[i + j * 2 * QMF_FILT_RESOLUTION]; - } - } - - for (i = 0; i < QMF_FILT_RESOLUTION; i++) { - output_real[i] = 0.0f; - output_imag[i] = 0.0f; - for (j = 0; j < 2 * QMF_FILT_RESOLUTION; j++) { - output_real[i] += (FLOAT32)(Y[j] * qmf_filt->ana_tab_real[i][j]); - output_imag[i] += (FLOAT32)(Y[j] * qmf_filt->ana_tab_imag[i][j]); - } - } -} - -static WORD32 impd_down_mix( - ia_drc_sel_proc_output_struct *uni_drc_sel_proc_output, - FLOAT32 **input_audio, WORD32 frame_len) { - WORD32 num_base_ch = uni_drc_sel_proc_output->base_channel_count; - WORD32 num_target_ch = uni_drc_sel_proc_output->target_channel_count; - WORD32 i, i_ch, o_ch; - FLOAT32 tmp_out[MAX_CHANNEL_COUNT]; - - if (num_target_ch > MAX_CHANNEL_COUNT) return -1; - - if (num_target_ch > num_base_ch) return -1; - - for (i = 0; i < frame_len; i++) { - for (o_ch = 0; o_ch < num_target_ch; o_ch++) { - tmp_out[o_ch] = 0.0f; - for (i_ch = 0; i_ch < num_base_ch; i_ch++) { - tmp_out[o_ch] += input_audio[i_ch][i] * - uni_drc_sel_proc_output->downmix_matrix[i_ch][o_ch]; - } - } - for (o_ch = 0; o_ch < num_target_ch; o_ch++) { - input_audio[o_ch][i] = tmp_out[o_ch]; - } - for (; o_ch < num_base_ch; o_ch++) { - input_audio[o_ch][i] = 0.0f; - } - } - - return 0; -} - -WORD32 impd_init_process_audio_main_td_qmf(ia_drc_api_struct *p_obj_drc) - -{ - WORD32 error, i, j, num_samples_per_channel; - FLOAT32 *input_buffer; - WORD16 *input_buffer16, *output_buffer16; - FLOAT32 *output_buffer; - FLOAT32 *audio_io_buf_real[10]; - FLOAT32 *audio_io_buf_imag[10]; - FLOAT32 *audio_in_out_buf[10]; - FLOAT32 *scratch_buffer; - WORD32 last_frame = 0; - error = 0; - scratch_buffer = (FLOAT32 *)p_obj_drc->pp_mem[1]; - input_buffer = (FLOAT32 *)p_obj_drc->pp_mem[2]; - output_buffer = (FLOAT32 *)p_obj_drc->pp_mem[3]; - - input_buffer16 = (WORD16 *)p_obj_drc->pp_mem[2]; - output_buffer16 = (WORD16 *)p_obj_drc->pp_mem[3]; - - if (p_obj_drc->p_state->ui_in_bytes <= 0) { - p_obj_drc->p_state->ui_out_bytes = 0; - return 0; - } - - if ((p_obj_drc->p_state->ui_in_bytes / p_obj_drc->str_config.num_ch_in / - (p_obj_drc->str_config.pcm_size >> 3)) < - (UWORD32)p_obj_drc->str_config.frame_size) - last_frame = 1; - - for (i = 0; i < p_obj_drc->str_config.num_ch_in; i++) { - audio_in_out_buf[i] = scratch_buffer; - scratch_buffer = scratch_buffer + (p_obj_drc->str_config.frame_size + 32); - audio_io_buf_real[i] = - scratch_buffer + - (p_obj_drc->str_config.frame_size * p_obj_drc->str_config.num_ch_in + - 512); - audio_io_buf_imag[i] = scratch_buffer + - 2 * (p_obj_drc->str_config.frame_size * - p_obj_drc->str_config.num_ch_in + - 512); - ; - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - if (p_obj_drc->str_config.pcm_size == 16) { - audio_in_out_buf[i][j] = - ((FLOAT32)input_buffer16[j * p_obj_drc->str_config.num_ch_in + i]) / - 32767.0f; - } else { - audio_in_out_buf[i][j] = - input_buffer[j * p_obj_drc->str_config.num_ch_in + i]; - } - } - } - - error = impd_process_drc_bitstream_dec_gain( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - if (p_obj_drc->str_bit_handler.gain_stream_flag == - 0) // ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - if (p_obj_drc->str_config.bitstream_file_format == - BITSTREAM_FILE_FORMAT_SPLIT) { - /* shift over fill-bits for frame byte alignment */ - if (p_obj_drc->str_bit_handler.num_bits_offset_bs != 0) { - p_obj_drc->str_bit_handler.num_bits_read_bs = - p_obj_drc->str_bit_handler.num_bits_read_bs + 8 - - p_obj_drc->str_bit_handler.num_bits_offset_bs; - p_obj_drc->str_bit_handler.num_bytes_read_bs = - p_obj_drc->str_bit_handler.num_bytes_read_bs + 1; - p_obj_drc->str_bit_handler.num_bits_offset_bs = 0; - p_obj_drc->str_bit_handler.byte_index_bs = - p_obj_drc->str_bit_handler.byte_index_bs + 1; - if (p_obj_drc->str_bit_handler.gain_stream_flag == - 0) // ITTIAM: Flag for applying gain frame by frame - { - p_obj_drc->str_bit_handler.num_bytes_bs = - p_obj_drc->str_bit_handler.num_bytes_bs - 1; - } - } - } - - for (i = 0; i < p_obj_drc->str_config.num_ch_in; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j += 64) { - process_qmf_ana_filt_bank( - p_obj_drc->str_payload.pstr_qmf_filter, - p_obj_drc->str_payload.pstr_qmf_filter->ana_buff + - i * 4 * p_obj_drc->str_config.frame_size, - &(audio_in_out_buf[i][j]), &(audio_io_buf_real[i][j]), - &(audio_io_buf_imag[i][j])); - } - } - error = impd_drc_process_freq_domain( - p_obj_drc->str_payload.pstr_gain_dec[0], - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, audio_io_buf_real, - audio_io_buf_imag, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, - p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->drc_characteristic_target); - - if (error) return error; - - if (p_obj_drc->str_payload.pstr_drc_sel_proc_output->target_channel_count < - p_obj_drc->str_payload.pstr_drc_sel_proc_output->base_channel_count) { - error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, - audio_io_buf_real, p_obj_drc->str_config.frame_size); - if (error) return error; - - error = impd_down_mix(p_obj_drc->str_payload.pstr_drc_sel_proc_output, - audio_io_buf_imag, p_obj_drc->str_config.frame_size); - if (error) return error; - } - - error = impd_drc_process_freq_domain( - p_obj_drc->str_payload.pstr_gain_dec[1], - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_drc_gain, audio_io_buf_real, - audio_io_buf_imag, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->boost, - p_obj_drc->str_payload.pstr_drc_sel_proc_output->compress, - p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->drc_characteristic_target); - if (error) return -1; - for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j += 64) { - process_qmf_syn_filt_bank( - p_obj_drc->str_payload.pstr_qmf_filter, - p_obj_drc->str_payload.pstr_qmf_filter->syn_buff + - i * 4 * p_obj_drc->str_config.frame_size, - &(audio_io_buf_real[i][j]), &(audio_io_buf_imag[i][j]), - &(audio_in_out_buf[i][j])); - } - } - - if (p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db != 0.0f) { - FLOAT32 loudness_normalization_gain = - (FLOAT32)pow(10.0, p_obj_drc->str_payload.pstr_drc_sel_proc_output - ->loudness_normalization_gain_db / - 20.0); - for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - audio_io_buf_real[i][j] *= loudness_normalization_gain; - audio_io_buf_imag[i][j] *= loudness_normalization_gain; - } - } - } - - num_samples_per_channel = p_obj_drc->str_config.frame_size; - - for (i = 0; i < p_obj_drc->str_config.num_ch_out; i++) { - for (j = 0; j < p_obj_drc->str_config.frame_size; j++) { - if (p_obj_drc->str_config.pcm_size == 16) { - output_buffer16[j * p_obj_drc->str_config.num_ch_out + i] = - (WORD16)(audio_in_out_buf[i][j] * 32767.0f); - } else { - output_buffer[j * p_obj_drc->str_config.num_ch_out + i] = - audio_in_out_buf[i][j]; - } - } - } - p_obj_drc->p_state->ui_out_bytes = - p_obj_drc->str_config.num_ch_out * - (p_obj_drc->p_state->ui_in_bytes / p_obj_drc->str_config.num_ch_in); - - if (p_obj_drc->str_config.bitstream_file_format != - BITSTREAM_FILE_FORMAT_SPLIT) { - error = impd_process_drc_bitstream_dec( - p_obj_drc->str_payload.pstr_bitstream_dec, p_obj_drc->pstr_bit_buf, - p_obj_drc->str_payload.pstr_drc_config, - p_obj_drc->str_payload.pstr_loudness_info, - &p_obj_drc->str_bit_handler - .it_bit_buf[p_obj_drc->str_bit_handler.byte_index_bs], - p_obj_drc->str_bit_handler.num_bytes_bs, - p_obj_drc->str_bit_handler.num_bits_offset_bs, - &p_obj_drc->str_bit_handler.num_bits_read_bs); - - if (error > PROC_COMPLETE) return -1; - - p_obj_drc->str_bit_handler.num_bytes_read_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs >> 3); - p_obj_drc->str_bit_handler.num_bits_offset_bs = - (p_obj_drc->str_bit_handler.num_bits_read_bs & 7); - p_obj_drc->str_bit_handler.byte_index_bs += - p_obj_drc->str_bit_handler.num_bytes_read_bs; - p_obj_drc->str_bit_handler.num_bytes_bs -= - p_obj_drc->str_bit_handler.num_bytes_read_bs; - } - - return error; -} diff --git a/decoder/drc_src/impd_drc_parametric_dec.c b/decoder/drc_src/impd_drc_parametric_dec.c index e4b3b4a..3b2063c 100644 --- a/decoder/drc_src/impd_drc_parametric_dec.c +++ b/decoder/drc_src/impd_drc_parametric_dec.c @@ -41,7 +41,7 @@ WORD32 impd_init_parametric_drc( WORD32 drc_frame_size, WORD32 sampling_rate, WORD32 sub_band_domain_mode, ia_parametric_drc_params_struct* p_parametricdrc_params) { - WORD32 sub_band_count_tbl[4] = {0, 64, 71, 256}; + static const WORD32 sub_band_count_tbl[4] = {0, 64, 71, 256}; p_parametricdrc_params->drc_frame_size = drc_frame_size; p_parametricdrc_params->sampling_rate = sampling_rate; p_parametricdrc_params->sub_band_domain_mode = sub_band_domain_mode; @@ -568,7 +568,7 @@ WORD32 impd_init_lvl_est_filt_subband( FLOAT32 w0, alpha, sinw0, cosw0; FLOAT32 b0, b1, b2, a0, a1, a2; FLOAT32 num_real, num_imag, den_real, den_imag; - FLOAT32* f_bands_nrm; + const FLOAT32* f_bands_nrm; WORD32 b; WORD32 i; const FLOAT32* ptr_samp_tbl; diff --git a/decoder/drc_src/impd_drc_process.c b/decoder/drc_src/impd_drc_process.c index 15115a2..45403ac 100644 --- a/decoder/drc_src/impd_drc_process.c +++ b/decoder/drc_src/impd_drc_process.c @@ -130,6 +130,9 @@ WORD32 impd_apply_gains_and_add( impd_shape_filt_block_adapt(lpcm_gains[iEnd], &shape_filter_block[g]); } + if ((iEnd == iStart) && + (drc_gain_last == shape_filter_block[g].drc_gain_last)) + break; iStart = iEnd; } } @@ -176,183 +179,6 @@ WORD32 impd_apply_gains_and_add( return (0); } -/* subband-domain DRC: in-place application of DRC gains to audio frame */ -WORD32 -impd_apply_gains_subband(ia_drc_instructions_struct* pstr_drc_instruction_arr, - const WORD32 drc_instructions_index, - ia_drc_params_struct* ia_drc_params_struct, - ia_gain_buffer_struct* pstr_gain_buf, - ia_overlap_params_struct* pstr_overlap_params, - FLOAT32* deinterleaved_audio_delayed_re[], - FLOAT32* deinterleaved_audio_delayed_im[], - FLOAT32* deinterleaved_audio_re[], - FLOAT32* deinterleaved_audio_im[]) { - WORD32 c, b, g, m, s; - WORD32 gainIndexForGroup[CHANNEL_GROUP_COUNT_MAX]; - FLOAT32* lpcm_gains; - FLOAT32 gainSb, gainLr; - ia_drc_instructions_struct* str_drc_instruction_str; - WORD32 offset = 0, signalIndex = 0; - WORD32 drc_frame_sizeSb = 0; - WORD32 nDecoderSubbands = 0; - WORD32 L = 0; /* L: downsampling factor */ - WORD32 analysisDelay = 0; - switch (ia_drc_params_struct->sub_band_domain_mode) { - case SUBBAND_DOMAIN_MODE_QMF64: - nDecoderSubbands = AUDIO_CODEC_SUBBAND_COUNT_QMF64; - L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64; - analysisDelay = AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF64; - break; - case SUBBAND_DOMAIN_MODE_QMF71: - nDecoderSubbands = AUDIO_CODEC_SUBBAND_COUNT_QMF71; - L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71; - analysisDelay = AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF71; - break; - case SUBBAND_DOMAIN_MODE_STFT256: - nDecoderSubbands = AUDIO_CODEC_SUBBAND_COUNT_STFT256; - L = AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256; - analysisDelay = AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_STFT256; - break; - default: - return -1; - break; - } - drc_frame_sizeSb = ia_drc_params_struct->drc_frame_size / L; - - if (drc_instructions_index >= 0) { - str_drc_instruction_str = - &(pstr_drc_instruction_arr[drc_instructions_index]); - { - if (str_drc_instruction_str->drc_set_id > 0) { - if (ia_drc_params_struct->delay_mode == DELAY_MODE_LOW_DELAY) { - offset = ia_drc_params_struct->drc_frame_size; - } - gainIndexForGroup[0] = 0; - for (g = 0; g < str_drc_instruction_str->num_drc_ch_groups - 1; g++) { - gainIndexForGroup[g + 1] = - gainIndexForGroup[g] + - str_drc_instruction_str - ->band_count_of_ch_group[g]; /* index of first gain sequence - in channel group */ - } - - for (c = 0; c < str_drc_instruction_str->audio_num_chan; c++) - - { - g = str_drc_instruction_str->channel_group_of_ch[c]; - if (g >= 0) { - for (m = 0; m < drc_frame_sizeSb; m++) { - if (str_drc_instruction_str->band_count_of_ch_group[g] > - 1) { /* multiband DRC */ - for (s = 0; s < nDecoderSubbands; s++) { - gainSb = 0.0f; - for (b = 0; - b < str_drc_instruction_str->band_count_of_ch_group[g]; - b++) { - if (str_drc_instruction_str - ->ch_group_parametric_drc_flag[g] == 0) { - lpcm_gains = - pstr_gain_buf - ->buf_interpolation[gainIndexForGroup[g] + b] - .lpcm_gains + - MAX_SIGNAL_DELAY - - ia_drc_params_struct->gain_delay_samples - - ia_drc_params_struct->audio_delay_samples + offset; - } else { - lpcm_gains = - pstr_gain_buf - ->buf_interpolation[gainIndexForGroup[g] + b] - .lpcm_gains + - MAX_SIGNAL_DELAY + - str_drc_instruction_str - ->parametric_drc_look_ahead_samples[g] - - ia_drc_params_struct->audio_delay_samples + - analysisDelay; - } - /* get gain for this timeslot by downsampling */ - gainLr = lpcm_gains[(m * L + (L - 1) / 2)]; - gainSb += pstr_overlap_params->str_group_overlap_params[g] - .str_band_overlap_params[b] - .overlap_weight[s] * - gainLr; - } - deinterleaved_audio_re[signalIndex][m * nDecoderSubbands + - s] = - gainSb * - deinterleaved_audio_delayed_re[signalIndex] - [m * nDecoderSubbands + s]; - if (ia_drc_params_struct->sub_band_domain_mode == - SUBBAND_DOMAIN_MODE_STFT256) { /* For STFT filterbank, the - real value of the - nyquist band is stored - at the imag value of the - first band */ - if (s != 0) - deinterleaved_audio_im[signalIndex][m * nDecoderSubbands + - s] = - gainSb * - deinterleaved_audio_delayed_im[signalIndex] - [m * nDecoderSubbands + - s]; - if (s == (nDecoderSubbands - 1)) - deinterleaved_audio_im[signalIndex][m * nDecoderSubbands + - 0] = - gainSb * - deinterleaved_audio_delayed_im[signalIndex] - [m * nDecoderSubbands + - 0]; - } else { - deinterleaved_audio_im[signalIndex][m * nDecoderSubbands + - s] = - gainSb * - deinterleaved_audio_delayed_im[signalIndex] - [m * nDecoderSubbands + - s]; - } - } - } else { /* single-band DRC */ - if (str_drc_instruction_str->ch_group_parametric_drc_flag[g] == - 0) { - lpcm_gains = - pstr_gain_buf->buf_interpolation[gainIndexForGroup[g]] - .lpcm_gains + - MAX_SIGNAL_DELAY - - ia_drc_params_struct->gain_delay_samples - - ia_drc_params_struct->audio_delay_samples + offset; - } else { - lpcm_gains = - pstr_gain_buf->buf_interpolation[gainIndexForGroup[g]] - .lpcm_gains + - MAX_SIGNAL_DELAY + - str_drc_instruction_str - ->parametric_drc_look_ahead_samples[g] - - ia_drc_params_struct->audio_delay_samples + analysisDelay; - } - /* get gain for this timeslot by downsampling */ - gainSb = lpcm_gains[(m * L + (L - 1) / 2)]; - for (s = 0; s < nDecoderSubbands; s++) { - deinterleaved_audio_re[signalIndex][m * nDecoderSubbands + - s] = - gainSb * - deinterleaved_audio_delayed_re[signalIndex] - [m * nDecoderSubbands + s]; - deinterleaved_audio_im[signalIndex][m * nDecoderSubbands + - s] = - gainSb * - deinterleaved_audio_delayed_im[signalIndex] - [m * nDecoderSubbands + s]; - } - } - } - } - signalIndex++; - } - } - } - } - return (0); -} - WORD32 impd_filter_banks_process(ia_drc_instructions_struct* pstr_drc_instruction_arr, const WORD32 drc_instructions_index, @@ -474,37 +300,6 @@ impd_store_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], } WORD32 -impd_store_audio_io_buffer_freq(FLOAT32* audio_real_buff[], - FLOAT32* audio_imag_buff[], - ia_audio_in_out_buf* audio_io_buf_internal) { - WORD32 i, j; - - if (audio_io_buf_internal->audio_delay_sub_band_samples) { - for (i = 0; i < audio_io_buf_internal->audio_num_chan; i++) { - for (j = 0; j < audio_io_buf_internal->audio_sub_band_frame_size * - audio_io_buf_internal->audio_sub_band_count; - j++) { - audio_io_buf_internal->audio_buffer_delayed_real - [i][audio_io_buf_internal->audio_delay_sub_band_samples * - audio_io_buf_internal->audio_sub_band_count + - j] = audio_real_buff[i][j]; - audio_io_buf_internal->audio_buffer_delayed_imag - [i][audio_io_buf_internal->audio_delay_sub_band_samples * - audio_io_buf_internal->audio_sub_band_count + - j] = audio_imag_buff[i][j]; - } - } - } else { - audio_io_buf_internal->audio_buffer_delayed_real = audio_real_buff; - audio_io_buf_internal->audio_buffer_delayed_imag = audio_imag_buff; - audio_io_buf_internal->audio_real_buff = audio_real_buff; - audio_io_buf_internal->audio_imag_buff = audio_imag_buff; - } - - return 0; -} - -WORD32 impd_retrieve_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], ia_audio_in_out_buf* audio_io_buf_internal) { WORD32 i, j; @@ -522,30 +317,6 @@ impd_retrieve_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], } WORD32 -impd_retrieve_audio_buffer_freq(FLOAT32* audio_real_buff[], - FLOAT32* audio_imag_buff[], - ia_audio_in_out_buf* audio_io_buf_internal) { - WORD32 i, j; - - if (audio_io_buf_internal->audio_delay_sub_band_samples) { - for (i = 0; i < audio_io_buf_internal->audio_num_chan; i++) { - for (j = 0; j < audio_io_buf_internal->audio_sub_band_frame_size * - audio_io_buf_internal->audio_sub_band_count; - j++) { - audio_real_buff[i][j] = - audio_io_buf_internal->audio_buffer_delayed_real - [i][audio_io_buf_internal->audio_sub_band_count + j]; - audio_imag_buff[i][j] = - audio_io_buf_internal->audio_buffer_delayed_imag - [i][audio_io_buf_internal->audio_sub_band_count + j]; - } - } - } - - return 0; -} - -WORD32 impd_advance_audio_io_buffer_time(ia_audio_in_out_buf* audio_io_buf_internal) { WORD32 i; if (audio_io_buf_internal->audio_delay_samples) { @@ -560,27 +331,3 @@ impd_advance_audio_io_buffer_time(ia_audio_in_out_buf* audio_io_buf_internal) { return 0; } - -WORD32 -impd_advance_audio_buff_freq(ia_audio_in_out_buf* audio_io_buf_internal) { - WORD32 i; - if (audio_io_buf_internal->audio_delay_sub_band_samples) { - for (i = 0; i < audio_io_buf_internal->audio_num_chan; i++) { - memmove(audio_io_buf_internal->audio_buffer_delayed_real[i], - &audio_io_buf_internal->audio_buffer_delayed_real - [i][audio_io_buf_internal->audio_sub_band_frame_size * - audio_io_buf_internal->audio_sub_band_count], - sizeof(FLOAT32) * - audio_io_buf_internal->audio_delay_sub_band_samples * - audio_io_buf_internal->audio_sub_band_count); - memmove(audio_io_buf_internal->audio_buffer_delayed_imag[i], - &audio_io_buf_internal->audio_buffer_delayed_imag - [i][audio_io_buf_internal->audio_sub_band_frame_size * - audio_io_buf_internal->audio_sub_band_count], - sizeof(FLOAT32) * - audio_io_buf_internal->audio_delay_sub_band_samples * - audio_io_buf_internal->audio_sub_band_count); - } - } - return 0; -} diff --git a/decoder/drc_src/impd_drc_process_audio.h b/decoder/drc_src/impd_drc_process_audio.h index 9a60280..2b1f6d5 100644 --- a/decoder/drc_src/impd_drc_process_audio.h +++ b/decoder/drc_src/impd_drc_process_audio.h @@ -46,17 +46,6 @@ typedef struct { } ia_audio_in_out_buf; WORD32 -impd_apply_gains_subband(ia_drc_instructions_struct* pstr_drc_instruction_arr, - const WORD32 drc_instructions_index, - ia_drc_params_struct* ia_drc_params_struct, - ia_gain_buffer_struct* pstr_gain_buf, - ia_overlap_params_struct* pstr_overlap_params, - FLOAT32* deinterleaved_audio_delayed_re[], - FLOAT32* deinterleaved_audio_delayed_im[], - FLOAT32* deinterleaved_audio_re[], - FLOAT32* deinterleaved_audio_im[]); - -WORD32 impd_filter_banks_process(ia_drc_instructions_struct* pstr_drc_instruction_arr, const WORD32 drc_instructions_index, ia_drc_params_struct* ia_drc_params_struct, @@ -79,15 +68,8 @@ impd_retrieve_audio_io_buffer_time(FLOAT32* audio_in_out_buf[], ia_audio_in_out_buf* audio_io_buf_internal); WORD32 -impd_retrieve_audio_buffer_freq(FLOAT32* audio_real_buff[], - FLOAT32* audio_imag_buff[], - ia_audio_in_out_buf* audio_io_buf_internal); - -WORD32 impd_advance_audio_io_buffer_time(ia_audio_in_out_buf* audio_io_buf_internal); -WORD32 -impd_advance_audio_buff_freq(ia_audio_in_out_buf* audio_io_buf_internal); #ifdef __cplusplus } diff --git a/decoder/drc_src/impd_drc_rom.c b/decoder/drc_src/impd_drc_rom.c index ad264bb..6925ae2 100644 --- a/decoder/drc_src/impd_drc_rom.c +++ b/decoder/drc_src/impd_drc_rom.c @@ -250,24 +250,33 @@ const FLOAT32 dwnmix_coeff_lfe[] = { 10.0f, 6.0f, 4.5f, 3.0f, 1.5f, 0.0f, -1.5f, -3.0f, -4.5f, -6.0f, -10.0f, -15.0f, -20.0f, -30.0f, -40.0f, -1000.0f}; -WORD32 drc_characteristic_order_default[][3] = { +const WORD32 drc_characteristic_order_default[][3] = { {1, 2, -1}, {2, 3, 1}, {3, 4, 2}, {4, 5, 3}, {5, 6, 4}, {6, 5, -1}, {7, 9, -1}, {8, 10, -1}, {9, 7, -1}, {10, 8, -1}, {11, 10, 9}}; -WORD32 measurement_system_default_tbl[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -WORD32 measurement_system_bs1770_3_tbl[] = {0, 0, 8, 0, 1, 3, 0, 5, 6, 7, 4, 2}; -WORD32 measurement_system_user_tbl[] = {0, 0, 1, 0, 8, 5, 0, 2, 3, 4, 6, 7}; -WORD32 measurement_system_expert_tbl[] = {0, 0, 3, 0, 1, 8, 0, 4, 5, 6, 7, 2}; -WORD32 measurement_system_rms_a_tbl[] = {0, 0, 5, 0, 1, 3, 0, 8, 6, 7, 4, 2}; -WORD32 measurement_system_rms_b_tbl[] = {0, 0, 5, 0, 1, 3, 0, 6, 8, 7, 4, 2}; -WORD32 measurement_system_rms_c_tbl[] = {0, 0, 5, 0, 1, 3, 0, 6, 7, 8, 4, 2}; -WORD32 measurement_system_rms_d_tbl[] = {0, 0, 3, 0, 1, 7, 0, 4, 5, 6, 8, 2}; -WORD32 measurement_system_rms_e_tbl[] = {0, 0, 1, 0, 7, 5, 0, 2, 3, 4, 6, 8}; +const WORD32 measurement_system_default_tbl[] = {0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0}; +const WORD32 measurement_system_bs1770_3_tbl[] = {0, 0, 8, 0, 1, 3, + 0, 5, 6, 7, 4, 2}; +const WORD32 measurement_system_user_tbl[] = {0, 0, 1, 0, 8, 5, + 0, 2, 3, 4, 6, 7}; +const WORD32 measurement_system_expert_tbl[] = {0, 0, 3, 0, 1, 8, + 0, 4, 5, 6, 7, 2}; +const WORD32 measurement_system_rms_a_tbl[] = {0, 0, 5, 0, 1, 3, + 0, 8, 6, 7, 4, 2}; +const WORD32 measurement_system_rms_b_tbl[] = {0, 0, 5, 0, 1, 3, + 0, 6, 8, 7, 4, 2}; +const WORD32 measurement_system_rms_c_tbl[] = {0, 0, 5, 0, 1, 3, + 0, 6, 7, 8, 4, 2}; +const WORD32 measurement_system_rms_d_tbl[] = {0, 0, 3, 0, 1, 7, + 0, 4, 5, 6, 8, 2}; +const WORD32 measurement_system_rms_e_tbl[] = {0, 0, 1, 0, 7, 5, + 0, 2, 3, 4, 6, 8}; -WORD32 measurement_method_prog_loudness_tbl[] = {0, 0, 1, 0, 0, 0, - 0, 2, 3, 4, 0, 0}; -WORD32 measurement_method_peak_loudness_tbl[] = {0, 7, 0, 0, 0, 0, - 6, 5, 4, 3, 2, 1}; +const WORD32 measurement_method_prog_loudness_tbl[] = {0, 0, 1, 0, 0, 0, + 0, 2, 3, 4, 0, 0}; +const WORD32 measurement_method_peak_loudness_tbl[] = {0, 7, 0, 0, 0, 0, + 6, 5, 4, 3, 2, 1}; const ia_loc_sys_interface_struct loc_sys_interface[] = { {0, 1, {0, 0, 0}, 0, 0}, {0, 1, {2, 0, 0}, 0, 0}, @@ -335,7 +344,7 @@ const ia_loc_drc_parameter_interface_struct loc_drc_parameter_interface[] = { {1.0f, 1.0f, 0}, {1.0f, 1.0f, 0}, }; -FLOAT32 f_bands_nrm_QMF71[71] = { +const FLOAT32 f_bands_nrm_QMF71[71] = { 0.004583300000000f, 0.000833330000000f, 0.002083300000000f, 0.005875000000000f, 0.009791700000000f, 0.014292000000000f, 0.019792000000000f, 0.027000000000000f, 0.035417000000000f, @@ -361,7 +370,7 @@ FLOAT32 f_bands_nrm_QMF71[71] = { 0.931750000000000f, 0.947370000000000f, 0.963000000000000f, 0.974540000000000f, 0.999040000000000f}; -FLOAT32 f_bands_nrm_QMF64[64] = { +const FLOAT32 f_bands_nrm_QMF64[64] = { 0.0078125000000000f, 0.0234380000000000f, 0.0390620000000000f, 0.0546880000000000f, 0.0703120000000000f, 0.0859380000000000f, 0.1015600000000000f, 0.1171900000000000f, 0.1328100000000000f, @@ -385,7 +394,7 @@ FLOAT32 f_bands_nrm_QMF64[64] = { 0.9453100000000000f, 0.9609400000000000f, 0.9765600000000000f, 0.9921900000000000f}; -FLOAT32 f_bands_nrm_STFT256[257] = { +const FLOAT32 f_bands_nrm_STFT256[257] = { 0.000000000000000f, 0.003906250000000f, 0.007812500000000f, 0.011718750000000f, 0.015625000000000f, 0.019531250000000f, 0.023437500000000f, 0.027343750000000f, 0.031250000000000f, @@ -473,646 +482,646 @@ FLOAT32 f_bands_nrm_STFT256[257] = { 0.984375000000000f, 0.988281250000000f, 0.992187500000000f, 0.996093750000000f, 1.000000000000000f}; -FLOAT64 qmf_filter_coeff[640] = {0, - -0.00055252865047, - -0.00056176925738, - -0.00049475180896, - -0.00048752279712, - -0.00048937912498, - -0.00050407143497, - -0.00052265642972, - -0.00054665656337, - -0.00056778025613, - -0.00058709304852, - -0.00061327473938, - -0.00063124935319, - -0.00065403333621, - -0.00067776907764, - -0.00069416146273, - -0.00071577364744, - -0.00072550431222, - -0.00074409418541, - -0.00074905980532, - -0.00076813719270, - -0.00077248485949, - -0.00078343322877, - -0.00077798694927, - -0.00078036647100, - -0.00078014496257, - -0.00077579773310, - -0.00076307935757, - -0.00075300014201, - -0.00073193571525, - -0.00072153919876, - -0.00069179375372, - -0.00066504150893, - -0.00063415949025, - -0.00059461189330, - -0.00055645763906, - -0.00051455722108, - -0.00046063254803, - -0.00040951214522, - -0.00035011758756, - -0.00028969811748, - -0.00020983373440, - -0.00014463809349, - -0.00006173344072, - 0.00001349497418, - 0.00010943831274, - 0.00020430170688, - 0.00029495311041, - 0.00040265402160, - 0.00051073884952, - 0.00062393761391, - 0.00074580258865, - 0.00086084433262, - 0.00098859883015, - 0.00112501551307, - 0.00125778846475, - 0.00139024948272, - 0.00154432198471, - 0.00168680832531, - 0.00183482654224, - 0.00198411407369, - 0.00214615835557, - 0.00230172547746, - 0.00246256169126, - 0.00262017586902, - 0.00278704643465, - 0.00294694477165, - 0.00311254206525, - 0.00327396134847, - 0.00344188741828, - 0.00360082681231, - 0.00376039229104, - 0.00392074323703, - 0.00408197531935, - 0.00422642692270, - 0.00437307196781, - 0.00452098527825, - 0.00466064606118, - 0.00479325608498, - 0.00491376035745, - 0.00503930226013, - 0.00514073539032, - 0.00524611661324, - 0.00534716811982, - 0.00541967759307, - 0.00548760401507, - 0.00554757145088, - 0.00559380230045, - 0.00562206432097, - 0.00564551969164, - 0.00563891995151, - 0.00562661141932, - 0.00559171286630, - 0.00554043639400, - 0.00547537830770, - 0.00538389758970, - 0.00527157587272, - 0.00513822754514, - 0.00498396877629, - 0.00481094690600, - 0.00460395301471, - 0.00438018617447, - 0.00412516423270, - 0.00384564081246, - 0.00354012465507, - 0.00320918858098, - 0.00284467578623, - 0.00245085400321, - 0.00202741761850, - 0.00157846825768, - 0.00109023290512, - 0.00058322642480, - 0.00002760451905, - -0.00054642808664, - -0.00115681355227, - -0.00180394725893, - -0.00248267236449, - -0.00319337783900, - -0.00394011240522, - -0.00472225962400, - -0.00553372111088, - -0.00637922932685, - -0.00726158168517, - -0.00817982333726, - -0.00913253296085, - -0.01011502154986, - -0.01113155480321, - -0.01218499959508, - 0.01327182200351, - 0.01439046660792, - 0.01554055533423, - 0.01673247129989, - 0.01794333813443, - 0.01918724313698, - 0.02045317933555, - 0.02174675502535, - 0.02306801692862, - 0.02441609920285, - 0.02578758475467, - 0.02718594296329, - 0.02860721736385, - 0.03005026574279, - 0.03150176087389, - 0.03297540810337, - 0.03446209487686, - 0.03596975605542, - 0.03748128504252, - 0.03900536794745, - 0.04053491705584, - 0.04206490946367, - 0.04360975421304, - 0.04514884056413, - 0.04668430272642, - 0.04821657200672, - 0.04973857556014, - 0.05125561555216, - 0.05276307465207, - 0.05424527683589, - 0.05571736482138, - 0.05716164501299, - 0.05859156836260, - 0.05998374801761, - 0.06134551717207, - 0.06268578081172, - 0.06397158980681, - 0.06522471064380, - 0.06643675122104, - 0.06760759851228, - 0.06870438283512, - 0.06976302447127, - 0.07076287107266, - 0.07170026731102, - 0.07256825833083, - 0.07336202550803, - 0.07410036424342, - 0.07474525581194, - 0.07531373362019, - 0.07580083586584, - 0.07619924793396, - 0.07649921704119, - 0.07670934904245, - 0.07681739756964, - 0.07682300113923, - 0.07672049241746, - 0.07650507183194, - 0.07617483218536, - 0.07573057565061, - 0.07515762552870, - 0.07446643947564, - 0.07364060057620, - 0.07267746427299, - 0.07158263647903, - 0.07035330735093, - 0.06896640131951, - 0.06745250215166, - 0.06576906686508, - 0.06394448059633, - 0.06196027790387, - 0.05981665708090, - 0.05751526919867, - 0.05504600343009, - 0.05240938217366, - 0.04959786763445, - 0.04663033051701, - 0.04347687821958, - 0.04014582784127, - 0.03664181168133, - 0.03295839306691, - 0.02908240060125, - 0.02503075618909, - 0.02079970728622, - 0.01637012582228, - 0.01176238327857, - 0.00696368621617, - 0.00197656014503, - -0.00320868968304, - -0.00857117491366, - -0.01412888273558, - -0.01988341292573, - -0.02582272888064, - -0.03195312745332, - -0.03827765720822, - -0.04478068215856, - -0.05148041767934, - -0.05837053268336, - -0.06544098531359, - -0.07269433008129, - -0.08013729344279, - -0.08775475365593, - -0.09555333528914, - -0.10353295311463, - -0.11168269317730, - -0.12000779846800, - -0.12850028503878, - -0.13715517611934, - -0.14597664911870, - -0.15496070710605, - -0.16409588556669, - -0.17338081721706, - -0.18281725485142, - -0.19239667457267, - -0.20212501768103, - -0.21197358538056, - -0.22196526964149, - -0.23206908706791, - -0.24230168845974, - -0.25264803095722, - -0.26310532994603, - -0.27366340405625, - -0.28432141891085, - -0.29507167170646, - -0.30590985751916, - -0.31682789136456, - -0.32781137272105, - -0.33887226938665, - -0.34999141229310, - 0.36115899031355, - 0.37237955463061, - 0.38363500139043, - 0.39492117615675, - 0.40623176767625, - 0.41756968968409, - 0.42891199207373, - 0.44025537543665, - 0.45159965356824, - 0.46293080852757, - 0.47424532146115, - 0.48552530911099, - 0.49677082545707, - 0.50798175000434, - 0.51912349702391, - 0.53022408956855, - 0.54125534487322, - 0.55220512585061, - 0.56307891401370, - 0.57385241316923, - 0.58454032354679, - 0.59511230862496, - 0.60557835389180, - 0.61591099320291, - 0.62612426956055, - 0.63619801077286, - 0.64612696959461, - 0.65590163024671, - 0.66551398801627, - 0.67496631901712, - 0.68423532934598, - 0.69332823767032, - 0.70223887193539, - 0.71094104263095, - 0.71944626349561, - 0.72774489002994, - 0.73582117582769, - 0.74368278636488, - 0.75131374561237, - 0.75870807608242, - 0.76586748650939, - 0.77277808813327, - 0.77942875190216, - 0.78583531203920, - 0.79197358416424, - 0.79784664137700, - 0.80344857518505, - 0.80876950044491, - 0.81381912706217, - 0.81857760046468, - 0.82304198905409, - 0.82722753473360, - 0.83110384571520, - 0.83469373618402, - 0.83797173378865, - 0.84095413924722, - 0.84362382812005, - 0.84598184698206, - 0.84803157770763, - 0.84978051984268, - 0.85119715249343, - 0.85230470352147, - 0.85310209497017, - 0.85357205739107, - 0.85373856005937, - 0.85357205739107, - 0.85310209497017, - 0.85230470352147, - 0.85119715249343, - 0.84978051984268, - 0.84803157770763, - 0.84598184698206, - 0.84362382812005, - 0.84095413924722, - 0.83797173378865, - 0.83469373618402, - 0.83110384571520, - 0.82722753473360, - 0.82304198905409, - 0.81857760046468, - 0.81381912706217, - 0.80876950044491, - 0.80344857518505, - 0.79784664137700, - 0.79197358416424, - 0.78583531203920, - 0.77942875190216, - 0.77277808813327, - 0.76586748650939, - 0.75870807608242, - 0.75131374561237, - 0.74368278636488, - 0.73582117582769, - 0.72774489002994, - 0.71944626349561, - 0.71094104263095, - 0.70223887193539, - 0.69332823767032, - 0.68423532934598, - 0.67496631901712, - 0.66551398801627, - 0.65590163024671, - 0.64612696959461, - 0.63619801077286, - 0.62612426956055, - 0.61591099320291, - 0.60557835389180, - 0.59511230862496, - 0.58454032354679, - 0.57385241316923, - 0.56307891401370, - 0.55220512585061, - 0.54125534487322, - 0.53022408956855, - 0.51912349702391, - 0.50798175000434, - 0.49677082545707, - 0.48552530911099, - 0.47424532146115, - 0.46293080852757, - 0.45159965356824, - 0.44025537543665, - 0.42891199207373, - 0.41756968968409, - 0.40623176767625, - 0.39492117615675, - 0.38363500139043, - 0.37237955463061, - -0.36115899031355, - -0.34999141229310, - -0.33887226938665, - -0.32781137272105, - -0.31682789136456, - -0.30590985751916, - -0.29507167170646, - -0.28432141891085, - -0.27366340405625, - -0.26310532994603, - -0.25264803095722, - -0.24230168845974, - -0.23206908706791, - -0.22196526964149, - -0.21197358538056, - -0.20212501768103, - -0.19239667457267, - -0.18281725485142, - -0.17338081721706, - -0.16409588556669, - -0.15496070710605, - -0.14597664911870, - -0.13715517611934, - -0.12850028503878, - -0.12000779846800, - -0.11168269317730, - -0.10353295311463, - -0.09555333528914, - -0.08775475365593, - -0.08013729344279, - -0.07269433008129, - -0.06544098531359, - -0.05837053268336, - -0.05148041767934, - -0.04478068215856, - -0.03827765720822, - -0.03195312745332, - -0.02582272888064, - -0.01988341292573, - -0.01412888273558, - -0.00857117491366, - -0.00320868968304, - 0.00197656014503, - 0.00696368621617, - 0.01176238327857, - 0.01637012582228, - 0.02079970728622, - 0.02503075618909, - 0.02908240060125, - 0.03295839306691, - 0.03664181168133, - 0.04014582784127, - 0.04347687821958, - 0.04663033051701, - 0.04959786763445, - 0.05240938217366, - 0.05504600343009, - 0.05751526919867, - 0.05981665708090, - 0.06196027790387, - 0.06394448059633, - 0.06576906686508, - 0.06745250215166, - 0.06896640131951, - 0.07035330735093, - 0.07158263647903, - 0.07267746427299, - 0.07364060057620, - 0.07446643947564, - 0.07515762552870, - 0.07573057565061, - 0.07617483218536, - 0.07650507183194, - 0.07672049241746, - 0.07682300113923, - 0.07681739756964, - 0.07670934904245, - 0.07649921704119, - 0.07619924793396, - 0.07580083586584, - 0.07531373362019, - 0.07474525581194, - 0.07410036424342, - 0.07336202550803, - 0.07256825833083, - 0.07170026731102, - 0.07076287107266, - 0.06976302447127, - 0.06870438283512, - 0.06760759851228, - 0.06643675122104, - 0.06522471064380, - 0.06397158980681, - 0.06268578081172, - 0.06134551717207, - 0.05998374801761, - 0.05859156836260, - 0.05716164501299, - 0.05571736482138, - 0.05424527683589, - 0.05276307465207, - 0.05125561555216, - 0.04973857556014, - 0.04821657200672, - 0.04668430272642, - 0.04514884056413, - 0.04360975421304, - 0.04206490946367, - 0.04053491705584, - 0.03900536794745, - 0.03748128504252, - 0.03596975605542, - 0.03446209487686, - 0.03297540810337, - 0.03150176087389, - 0.03005026574279, - 0.02860721736385, - 0.02718594296329, - 0.02578758475467, - 0.02441609920285, - 0.02306801692862, - 0.02174675502535, - 0.02045317933555, - 0.01918724313698, - 0.01794333813443, - 0.01673247129989, - 0.01554055533423, - 0.01439046660792, - -0.01327182200351, - -0.01218499959508, - -0.01113155480321, - -0.01011502154986, - -0.00913253296085, - -0.00817982333726, - -0.00726158168517, - -0.00637922932685, - -0.00553372111088, - -0.00472225962400, - -0.00394011240522, - -0.00319337783900, - -0.00248267236449, - -0.00180394725893, - -0.00115681355227, - -0.00054642808664, - 0.00002760451905, - 0.00058322642480, - 0.00109023290512, - 0.00157846825768, - 0.00202741761850, - 0.00245085400321, - 0.00284467578623, - 0.00320918858098, - 0.00354012465507, - 0.00384564081246, - 0.00412516423270, - 0.00438018617447, - 0.00460395301471, - 0.00481094690600, - 0.00498396877629, - 0.00513822754514, - 0.00527157587272, - 0.00538389758970, - 0.00547537830770, - 0.00554043639400, - 0.00559171286630, - 0.00562661141932, - 0.00563891995151, - 0.00564551969164, - 0.00562206432097, - 0.00559380230045, - 0.00554757145088, - 0.00548760401507, - 0.00541967759307, - 0.00534716811982, - 0.00524611661324, - 0.00514073539032, - 0.00503930226013, - 0.00491376035745, - 0.00479325608498, - 0.00466064606118, - 0.00452098527825, - 0.00437307196781, - 0.00422642692270, - 0.00408197531935, - 0.00392074323703, - 0.00376039229104, - 0.00360082681231, - 0.00344188741828, - 0.00327396134847, - 0.00311254206525, - 0.00294694477165, - 0.00278704643465, - 0.00262017586902, - 0.00246256169126, - 0.00230172547746, - 0.00214615835557, - 0.00198411407369, - 0.00183482654224, - 0.00168680832531, - 0.00154432198471, - 0.00139024948272, - 0.00125778846475, - 0.00112501551307, - 0.00098859883015, - 0.00086084433262, - 0.00074580258865, - 0.00062393761391, - 0.00051073884952, - 0.00040265402160, - 0.00029495311041, - 0.00020430170688, - 0.00010943831274, - 0.00001349497418, - -0.00006173344072, - -0.00014463809349, - -0.00020983373440, - -0.00028969811748, - -0.00035011758756, - -0.00040951214522, - -0.00046063254803, - -0.00051455722108, - -0.00055645763906, - -0.00059461189330, - -0.00063415949025, - -0.00066504150893, - -0.00069179375372, - -0.00072153919876, - -0.00073193571525, - -0.00075300014201, - -0.00076307935757, - -0.00077579773310, - -0.00078014496257, - -0.00078036647100, - -0.00077798694927, - -0.00078343322877, - -0.00077248485949, - -0.00076813719270, - -0.00074905980532, - -0.00074409418541, - -0.00072550431222, - -0.00071577364744, - -0.00069416146273, - -0.00067776907764, - -0.00065403333621, - -0.00063124935319, - -0.00061327473938, - -0.00058709304852, - -0.00056778025613, - -0.00054665656337, - -0.00052265642972, - -0.00050407143497, - -0.00048937912498, - -0.00048752279712, - -0.00049475180896, - -0.00056176925738, - -0.00055252865047}; +const FLOAT64 qmf_filter_coeff[640] = {0, + -0.00055252865047, + -0.00056176925738, + -0.00049475180896, + -0.00048752279712, + -0.00048937912498, + -0.00050407143497, + -0.00052265642972, + -0.00054665656337, + -0.00056778025613, + -0.00058709304852, + -0.00061327473938, + -0.00063124935319, + -0.00065403333621, + -0.00067776907764, + -0.00069416146273, + -0.00071577364744, + -0.00072550431222, + -0.00074409418541, + -0.00074905980532, + -0.00076813719270, + -0.00077248485949, + -0.00078343322877, + -0.00077798694927, + -0.00078036647100, + -0.00078014496257, + -0.00077579773310, + -0.00076307935757, + -0.00075300014201, + -0.00073193571525, + -0.00072153919876, + -0.00069179375372, + -0.00066504150893, + -0.00063415949025, + -0.00059461189330, + -0.00055645763906, + -0.00051455722108, + -0.00046063254803, + -0.00040951214522, + -0.00035011758756, + -0.00028969811748, + -0.00020983373440, + -0.00014463809349, + -0.00006173344072, + 0.00001349497418, + 0.00010943831274, + 0.00020430170688, + 0.00029495311041, + 0.00040265402160, + 0.00051073884952, + 0.00062393761391, + 0.00074580258865, + 0.00086084433262, + 0.00098859883015, + 0.00112501551307, + 0.00125778846475, + 0.00139024948272, + 0.00154432198471, + 0.00168680832531, + 0.00183482654224, + 0.00198411407369, + 0.00214615835557, + 0.00230172547746, + 0.00246256169126, + 0.00262017586902, + 0.00278704643465, + 0.00294694477165, + 0.00311254206525, + 0.00327396134847, + 0.00344188741828, + 0.00360082681231, + 0.00376039229104, + 0.00392074323703, + 0.00408197531935, + 0.00422642692270, + 0.00437307196781, + 0.00452098527825, + 0.00466064606118, + 0.00479325608498, + 0.00491376035745, + 0.00503930226013, + 0.00514073539032, + 0.00524611661324, + 0.00534716811982, + 0.00541967759307, + 0.00548760401507, + 0.00554757145088, + 0.00559380230045, + 0.00562206432097, + 0.00564551969164, + 0.00563891995151, + 0.00562661141932, + 0.00559171286630, + 0.00554043639400, + 0.00547537830770, + 0.00538389758970, + 0.00527157587272, + 0.00513822754514, + 0.00498396877629, + 0.00481094690600, + 0.00460395301471, + 0.00438018617447, + 0.00412516423270, + 0.00384564081246, + 0.00354012465507, + 0.00320918858098, + 0.00284467578623, + 0.00245085400321, + 0.00202741761850, + 0.00157846825768, + 0.00109023290512, + 0.00058322642480, + 0.00002760451905, + -0.00054642808664, + -0.00115681355227, + -0.00180394725893, + -0.00248267236449, + -0.00319337783900, + -0.00394011240522, + -0.00472225962400, + -0.00553372111088, + -0.00637922932685, + -0.00726158168517, + -0.00817982333726, + -0.00913253296085, + -0.01011502154986, + -0.01113155480321, + -0.01218499959508, + 0.01327182200351, + 0.01439046660792, + 0.01554055533423, + 0.01673247129989, + 0.01794333813443, + 0.01918724313698, + 0.02045317933555, + 0.02174675502535, + 0.02306801692862, + 0.02441609920285, + 0.02578758475467, + 0.02718594296329, + 0.02860721736385, + 0.03005026574279, + 0.03150176087389, + 0.03297540810337, + 0.03446209487686, + 0.03596975605542, + 0.03748128504252, + 0.03900536794745, + 0.04053491705584, + 0.04206490946367, + 0.04360975421304, + 0.04514884056413, + 0.04668430272642, + 0.04821657200672, + 0.04973857556014, + 0.05125561555216, + 0.05276307465207, + 0.05424527683589, + 0.05571736482138, + 0.05716164501299, + 0.05859156836260, + 0.05998374801761, + 0.06134551717207, + 0.06268578081172, + 0.06397158980681, + 0.06522471064380, + 0.06643675122104, + 0.06760759851228, + 0.06870438283512, + 0.06976302447127, + 0.07076287107266, + 0.07170026731102, + 0.07256825833083, + 0.07336202550803, + 0.07410036424342, + 0.07474525581194, + 0.07531373362019, + 0.07580083586584, + 0.07619924793396, + 0.07649921704119, + 0.07670934904245, + 0.07681739756964, + 0.07682300113923, + 0.07672049241746, + 0.07650507183194, + 0.07617483218536, + 0.07573057565061, + 0.07515762552870, + 0.07446643947564, + 0.07364060057620, + 0.07267746427299, + 0.07158263647903, + 0.07035330735093, + 0.06896640131951, + 0.06745250215166, + 0.06576906686508, + 0.06394448059633, + 0.06196027790387, + 0.05981665708090, + 0.05751526919867, + 0.05504600343009, + 0.05240938217366, + 0.04959786763445, + 0.04663033051701, + 0.04347687821958, + 0.04014582784127, + 0.03664181168133, + 0.03295839306691, + 0.02908240060125, + 0.02503075618909, + 0.02079970728622, + 0.01637012582228, + 0.01176238327857, + 0.00696368621617, + 0.00197656014503, + -0.00320868968304, + -0.00857117491366, + -0.01412888273558, + -0.01988341292573, + -0.02582272888064, + -0.03195312745332, + -0.03827765720822, + -0.04478068215856, + -0.05148041767934, + -0.05837053268336, + -0.06544098531359, + -0.07269433008129, + -0.08013729344279, + -0.08775475365593, + -0.09555333528914, + -0.10353295311463, + -0.11168269317730, + -0.12000779846800, + -0.12850028503878, + -0.13715517611934, + -0.14597664911870, + -0.15496070710605, + -0.16409588556669, + -0.17338081721706, + -0.18281725485142, + -0.19239667457267, + -0.20212501768103, + -0.21197358538056, + -0.22196526964149, + -0.23206908706791, + -0.24230168845974, + -0.25264803095722, + -0.26310532994603, + -0.27366340405625, + -0.28432141891085, + -0.29507167170646, + -0.30590985751916, + -0.31682789136456, + -0.32781137272105, + -0.33887226938665, + -0.34999141229310, + 0.36115899031355, + 0.37237955463061, + 0.38363500139043, + 0.39492117615675, + 0.40623176767625, + 0.41756968968409, + 0.42891199207373, + 0.44025537543665, + 0.45159965356824, + 0.46293080852757, + 0.47424532146115, + 0.48552530911099, + 0.49677082545707, + 0.50798175000434, + 0.51912349702391, + 0.53022408956855, + 0.54125534487322, + 0.55220512585061, + 0.56307891401370, + 0.57385241316923, + 0.58454032354679, + 0.59511230862496, + 0.60557835389180, + 0.61591099320291, + 0.62612426956055, + 0.63619801077286, + 0.64612696959461, + 0.65590163024671, + 0.66551398801627, + 0.67496631901712, + 0.68423532934598, + 0.69332823767032, + 0.70223887193539, + 0.71094104263095, + 0.71944626349561, + 0.72774489002994, + 0.73582117582769, + 0.74368278636488, + 0.75131374561237, + 0.75870807608242, + 0.76586748650939, + 0.77277808813327, + 0.77942875190216, + 0.78583531203920, + 0.79197358416424, + 0.79784664137700, + 0.80344857518505, + 0.80876950044491, + 0.81381912706217, + 0.81857760046468, + 0.82304198905409, + 0.82722753473360, + 0.83110384571520, + 0.83469373618402, + 0.83797173378865, + 0.84095413924722, + 0.84362382812005, + 0.84598184698206, + 0.84803157770763, + 0.84978051984268, + 0.85119715249343, + 0.85230470352147, + 0.85310209497017, + 0.85357205739107, + 0.85373856005937, + 0.85357205739107, + 0.85310209497017, + 0.85230470352147, + 0.85119715249343, + 0.84978051984268, + 0.84803157770763, + 0.84598184698206, + 0.84362382812005, + 0.84095413924722, + 0.83797173378865, + 0.83469373618402, + 0.83110384571520, + 0.82722753473360, + 0.82304198905409, + 0.81857760046468, + 0.81381912706217, + 0.80876950044491, + 0.80344857518505, + 0.79784664137700, + 0.79197358416424, + 0.78583531203920, + 0.77942875190216, + 0.77277808813327, + 0.76586748650939, + 0.75870807608242, + 0.75131374561237, + 0.74368278636488, + 0.73582117582769, + 0.72774489002994, + 0.71944626349561, + 0.71094104263095, + 0.70223887193539, + 0.69332823767032, + 0.68423532934598, + 0.67496631901712, + 0.66551398801627, + 0.65590163024671, + 0.64612696959461, + 0.63619801077286, + 0.62612426956055, + 0.61591099320291, + 0.60557835389180, + 0.59511230862496, + 0.58454032354679, + 0.57385241316923, + 0.56307891401370, + 0.55220512585061, + 0.54125534487322, + 0.53022408956855, + 0.51912349702391, + 0.50798175000434, + 0.49677082545707, + 0.48552530911099, + 0.47424532146115, + 0.46293080852757, + 0.45159965356824, + 0.44025537543665, + 0.42891199207373, + 0.41756968968409, + 0.40623176767625, + 0.39492117615675, + 0.38363500139043, + 0.37237955463061, + -0.36115899031355, + -0.34999141229310, + -0.33887226938665, + -0.32781137272105, + -0.31682789136456, + -0.30590985751916, + -0.29507167170646, + -0.28432141891085, + -0.27366340405625, + -0.26310532994603, + -0.25264803095722, + -0.24230168845974, + -0.23206908706791, + -0.22196526964149, + -0.21197358538056, + -0.20212501768103, + -0.19239667457267, + -0.18281725485142, + -0.17338081721706, + -0.16409588556669, + -0.15496070710605, + -0.14597664911870, + -0.13715517611934, + -0.12850028503878, + -0.12000779846800, + -0.11168269317730, + -0.10353295311463, + -0.09555333528914, + -0.08775475365593, + -0.08013729344279, + -0.07269433008129, + -0.06544098531359, + -0.05837053268336, + -0.05148041767934, + -0.04478068215856, + -0.03827765720822, + -0.03195312745332, + -0.02582272888064, + -0.01988341292573, + -0.01412888273558, + -0.00857117491366, + -0.00320868968304, + 0.00197656014503, + 0.00696368621617, + 0.01176238327857, + 0.01637012582228, + 0.02079970728622, + 0.02503075618909, + 0.02908240060125, + 0.03295839306691, + 0.03664181168133, + 0.04014582784127, + 0.04347687821958, + 0.04663033051701, + 0.04959786763445, + 0.05240938217366, + 0.05504600343009, + 0.05751526919867, + 0.05981665708090, + 0.06196027790387, + 0.06394448059633, + 0.06576906686508, + 0.06745250215166, + 0.06896640131951, + 0.07035330735093, + 0.07158263647903, + 0.07267746427299, + 0.07364060057620, + 0.07446643947564, + 0.07515762552870, + 0.07573057565061, + 0.07617483218536, + 0.07650507183194, + 0.07672049241746, + 0.07682300113923, + 0.07681739756964, + 0.07670934904245, + 0.07649921704119, + 0.07619924793396, + 0.07580083586584, + 0.07531373362019, + 0.07474525581194, + 0.07410036424342, + 0.07336202550803, + 0.07256825833083, + 0.07170026731102, + 0.07076287107266, + 0.06976302447127, + 0.06870438283512, + 0.06760759851228, + 0.06643675122104, + 0.06522471064380, + 0.06397158980681, + 0.06268578081172, + 0.06134551717207, + 0.05998374801761, + 0.05859156836260, + 0.05716164501299, + 0.05571736482138, + 0.05424527683589, + 0.05276307465207, + 0.05125561555216, + 0.04973857556014, + 0.04821657200672, + 0.04668430272642, + 0.04514884056413, + 0.04360975421304, + 0.04206490946367, + 0.04053491705584, + 0.03900536794745, + 0.03748128504252, + 0.03596975605542, + 0.03446209487686, + 0.03297540810337, + 0.03150176087389, + 0.03005026574279, + 0.02860721736385, + 0.02718594296329, + 0.02578758475467, + 0.02441609920285, + 0.02306801692862, + 0.02174675502535, + 0.02045317933555, + 0.01918724313698, + 0.01794333813443, + 0.01673247129989, + 0.01554055533423, + 0.01439046660792, + -0.01327182200351, + -0.01218499959508, + -0.01113155480321, + -0.01011502154986, + -0.00913253296085, + -0.00817982333726, + -0.00726158168517, + -0.00637922932685, + -0.00553372111088, + -0.00472225962400, + -0.00394011240522, + -0.00319337783900, + -0.00248267236449, + -0.00180394725893, + -0.00115681355227, + -0.00054642808664, + 0.00002760451905, + 0.00058322642480, + 0.00109023290512, + 0.00157846825768, + 0.00202741761850, + 0.00245085400321, + 0.00284467578623, + 0.00320918858098, + 0.00354012465507, + 0.00384564081246, + 0.00412516423270, + 0.00438018617447, + 0.00460395301471, + 0.00481094690600, + 0.00498396877629, + 0.00513822754514, + 0.00527157587272, + 0.00538389758970, + 0.00547537830770, + 0.00554043639400, + 0.00559171286630, + 0.00562661141932, + 0.00563891995151, + 0.00564551969164, + 0.00562206432097, + 0.00559380230045, + 0.00554757145088, + 0.00548760401507, + 0.00541967759307, + 0.00534716811982, + 0.00524611661324, + 0.00514073539032, + 0.00503930226013, + 0.00491376035745, + 0.00479325608498, + 0.00466064606118, + 0.00452098527825, + 0.00437307196781, + 0.00422642692270, + 0.00408197531935, + 0.00392074323703, + 0.00376039229104, + 0.00360082681231, + 0.00344188741828, + 0.00327396134847, + 0.00311254206525, + 0.00294694477165, + 0.00278704643465, + 0.00262017586902, + 0.00246256169126, + 0.00230172547746, + 0.00214615835557, + 0.00198411407369, + 0.00183482654224, + 0.00168680832531, + 0.00154432198471, + 0.00139024948272, + 0.00125778846475, + 0.00112501551307, + 0.00098859883015, + 0.00086084433262, + 0.00074580258865, + 0.00062393761391, + 0.00051073884952, + 0.00040265402160, + 0.00029495311041, + 0.00020430170688, + 0.00010943831274, + 0.00001349497418, + -0.00006173344072, + -0.00014463809349, + -0.00020983373440, + -0.00028969811748, + -0.00035011758756, + -0.00040951214522, + -0.00046063254803, + -0.00051455722108, + -0.00055645763906, + -0.00059461189330, + -0.00063415949025, + -0.00066504150893, + -0.00069179375372, + -0.00072153919876, + -0.00073193571525, + -0.00075300014201, + -0.00076307935757, + -0.00077579773310, + -0.00078014496257, + -0.00078036647100, + -0.00077798694927, + -0.00078343322877, + -0.00077248485949, + -0.00076813719270, + -0.00074905980532, + -0.00074409418541, + -0.00072550431222, + -0.00071577364744, + -0.00069416146273, + -0.00067776907764, + -0.00065403333621, + -0.00063124935319, + -0.00061327473938, + -0.00058709304852, + -0.00056778025613, + -0.00054665656337, + -0.00052265642972, + -0.00050407143497, + -0.00048937912498, + -0.00048752279712, + -0.00049475180896, + -0.00056176925738, + -0.00055252865047}; const ia_filter_bank_params_struct normal_cross_freq[FILTER_BANK_PARAMETER_COUNT] = { diff --git a/decoder/drc_src/impd_drc_rom.h b/decoder/drc_src/impd_drc_rom.h index 9add85d..d9432fd 100644 --- a/decoder/drc_src/impd_drc_rom.h +++ b/decoder/drc_src/impd_drc_rom.h @@ -66,20 +66,20 @@ extern const FLOAT32 dwnmix_coeff[]; extern const FLOAT32 dwnmix_coeff_lfe[]; -extern WORD32 drc_characteristic_order_default[][3]; +extern const WORD32 drc_characteristic_order_default[][3]; -extern WORD32 measurement_system_default_tbl[]; +extern const WORD32 measurement_system_default_tbl[]; -extern WORD32 measurement_system_bs1770_3_tbl[]; -extern WORD32 measurement_system_user_tbl[]; -extern WORD32 measurement_system_expert_tbl[]; -extern WORD32 measurement_system_rms_a_tbl[]; -extern WORD32 measurement_system_rms_b_tbl[]; -extern WORD32 measurement_system_rms_c_tbl[]; -extern WORD32 measurement_system_rms_d_tbl[]; -extern WORD32 measurement_system_rms_e_tbl[]; -extern WORD32 measurement_method_prog_loudness_tbl[]; -extern WORD32 measurement_method_peak_loudness_tbl[]; +extern const WORD32 measurement_system_bs1770_3_tbl[]; +extern const WORD32 measurement_system_user_tbl[]; +extern const WORD32 measurement_system_expert_tbl[]; +extern const WORD32 measurement_system_rms_a_tbl[]; +extern const WORD32 measurement_system_rms_b_tbl[]; +extern const WORD32 measurement_system_rms_c_tbl[]; +extern const WORD32 measurement_system_rms_d_tbl[]; +extern const WORD32 measurement_system_rms_e_tbl[]; +extern const WORD32 measurement_method_prog_loudness_tbl[]; +extern const WORD32 measurement_method_peak_loudness_tbl[]; #define MAX_NUM_DOWNMIX_ID_REQUESTS_LOCAL 3 @@ -151,11 +151,11 @@ typedef struct { extern const ia_loc_drc_parameter_interface_struct loc_drc_parameter_interface[]; -extern FLOAT32 f_bands_nrm_QMF71[71]; -extern FLOAT32 f_bands_nrm_QMF64[64]; -extern FLOAT32 f_bands_nrm_STFT256[257]; +extern const FLOAT32 f_bands_nrm_QMF71[71]; +extern const FLOAT32 f_bands_nrm_QMF64[64]; +extern const FLOAT32 f_bands_nrm_STFT256[257]; -FLOAT64 qmf_filter_coeff[640]; +extern const FLOAT64 qmf_filter_coeff[640]; extern const ia_filter_bank_params_struct normal_cross_freq[FILTER_BANK_PARAMETER_COUNT]; diff --git a/decoder/drc_src/impd_drc_selection_process.c b/decoder/drc_src/impd_drc_selection_process.c index 57f8b9c..ac24a40 100644 --- a/decoder/drc_src/impd_drc_selection_process.c +++ b/decoder/drc_src/impd_drc_selection_process.c @@ -129,7 +129,6 @@ impd_drc_uni_sel_proc_process( pstr_drc_uni_sel_proc->loudness_info_set_flag || pstr_drc_uni_sel_proc->sel_proc_request_flag) { WORD32 repeat_selection = 1; - WORD32 loop_cnt = 0; err = impd_manage_drc_complexity(pstr_drc_uni_sel_proc, pstr_drc_config); if (err) return (err); @@ -170,9 +169,10 @@ impd_drc_uni_sel_proc_process( for (i = SUB_DRC_COUNT - 1; i >= 0; i--) { WORD32 drc_instructions_index = pstr_drc_uni_sel_proc->drc_instructions_index[i]; + ia_drc_instructions_struct* str_drc_instruction_str; if (drc_instructions_index < 0) continue; - ia_drc_instructions_struct* str_drc_instruction_str = + str_drc_instruction_str = &(pstr_drc_uni_sel_proc->drc_config .str_drc_instruction_str[drc_instructions_index]); @@ -213,11 +213,6 @@ impd_drc_uni_sel_proc_process( err = impd_manage_complexity(pstr_drc_uni_sel_proc, pstr_drc_config, &repeat_selection); if (err) return (err); - - loop_cnt++; - if (loop_cnt > 100) { - return (UNEXPECTED_ERROR); - } } pstr_drc_uni_sel_proc->sel_proc_request_flag = 0; diff --git a/decoder/drc_src/impd_drc_selection_process_drcset_selection.c b/decoder/drc_src/impd_drc_selection_process_drcset_selection.c index 7e2bb62..3cd5ad5 100644 --- a/decoder/drc_src/impd_drc_selection_process_drcset_selection.c +++ b/decoder/drc_src/impd_drc_selection_process_drcset_selection.c @@ -31,7 +31,7 @@ #include "impd_drc_filter_bank.h" #include "impd_drc_rom.h" -static WORD32 effect_types_request_table[] = { +static const WORD32 effect_types_request_table[] = { EFFECT_BIT_NIGHT, EFFECT_BIT_NOISY, EFFECT_BIT_LIMITED, EFFECT_BIT_LOWLEVEL, EFFECT_BIT_DIALOG, EFFECT_BIT_GENERAL_COMPR, EFFECT_BIT_EXPAND, EFFECT_BIT_ARTISTIC}; @@ -673,9 +673,9 @@ WORD32 impd_match_drc_characteristic( WORD32 k, err; WORD32 match_found_flag = 0; - WORD32* drc_characteristic_order = + const WORD32* drc_characteristic_order = drc_characteristic_order_default[requested_drc_characteristic - 1]; - WORD32 drc_characteristic_order_count = + const WORD32 drc_characteristic_order_count = sizeof(drc_characteristic_order_default[requested_drc_characteristic]) / sizeof(WORD32); k = 0; @@ -910,6 +910,7 @@ WORD32 impd_drc_set_preselection( for (l = 0; l < loudness_info_count; l++) { WORD32 match_found_flag = 0; WORD32 p; + if (k >= SELECTION_CANDIDATE_COUNT_MAX) return UNEXPECTED_ERROR; for (p = 0; p < peak_info_count; p++) { if (eq_set_id_Peak[p] == eq_set_id_loudness[l]) { if (eq_set_id_valid_flag[eq_set_id_Peak[p]] == 1) { @@ -924,7 +925,6 @@ WORD32 impd_drc_set_preselection( signal_peak_level[p] + loudness_normalization_gain_db[l] - pstr_drc_sel_proc_params_struct->output_peak_level_max); adjustment = min(adjustment, max(0.0f, loudness_deviation_max)); - if (k >= SELECTION_CANDIDATE_COUNT_MAX) return UNEXPECTED_ERROR; selection_candidate_info[k].loudness_norm_db_gain_adjusted = loudness_normalization_gain_db[l] - adjustment; @@ -967,11 +967,9 @@ WORD32 impd_drc_set_preselection( } } } + if (k > SELECTION_CANDIDATE_COUNT_MAX) return UNEXPECTED_ERROR; *selection_candidate_count = k; - - if (*selection_candidate_count > SELECTION_CANDIDATE_COUNT_MAX) { - return UNEXPECTED_ERROR; - } else if (pstr_drc_sel_proc_params_struct->dynamic_range_control_on == 1) { + if (pstr_drc_sel_proc_params_struct->dynamic_range_control_on == 1) { n = 0; for (k = 0; k < *selection_candidate_count; k++) { str_drc_instruction_str = @@ -1172,6 +1170,7 @@ WORD32 impd_drc_set_final_selection( if (pstr_drc_sel_proc_params_struct->requested_dwnmix_id [selection_candidate_info_step_2[i].downmix_id_request_index] == str_drc_instruction_str->downmix_id[n]) { + if (k >= SELECTION_CANDIDATE_COUNT_MAX) return UNEXPECTED_ERROR; memcpy(&selection_candidate_info_step_2[k], &selection_candidate_info_step_2[i], sizeof(ia_selection_candidate_info_struct)); diff --git a/decoder/drc_src/impd_drc_static_payload.c b/decoder/drc_src/impd_drc_static_payload.c index 95f5aeb..890555c 100644 --- a/decoder/drc_src/impd_drc_static_payload.c +++ b/decoder/drc_src/impd_drc_static_payload.c @@ -338,7 +338,7 @@ impd_parametric_drc_parse_gain_set_params( str_parametric_drc_gain_set_params->parametric_drc_id = (temp >> 3) & 0xf; str_parametric_drc_gain_set_params->side_chain_config_type = temp & 7; - if (str_parametric_drc_gain_set_params->side_chain_config_type) { + if (str_parametric_drc_gain_set_params->side_chain_config_type == 1) { temp = impd_read_bits_buf(it_bit_buff, 8); if (it_bit_buff->error) return it_bit_buff->error; @@ -443,9 +443,13 @@ static WORD32 impd_parametric_drc_gen_virtual_gain_sets( str_p_loc_drc_coefficients_uni_drc->gain_sequence_count = 0; drc_config->drc_coefficients_drc_count += 1; } - str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = - str_p_loc_drc_coefficients_uni_drc->gain_set_count + - str_drc_coeff_param_drc->parametric_drc_gain_set_count; + { + WORD32 tmp = str_p_loc_drc_coefficients_uni_drc->gain_set_count + + str_drc_coeff_param_drc->parametric_drc_gain_set_count; + if (tmp > GAIN_SET_COUNT_MAX) return UNEXPECTED_ERROR; + str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus = tmp; + } + for (i = str_p_loc_drc_coefficients_uni_drc->gain_set_count; i < str_p_loc_drc_coefficients_uni_drc->gain_set_count_plus; i++) { str_p_loc_drc_coefficients_uni_drc->gain_set_params[i].band_count = 1; @@ -518,9 +522,12 @@ static WORD32 impd_parametic_drc_parse_coeff( if (it_bit_buff->error) return it_bit_buff->error; str_drc_coeff_param_drc->drc_location = (temp >> 1) & 0xf; + if (str_drc_coeff_param_drc->drc_location < 1 || + str_drc_coeff_param_drc->drc_location > 4) + return UNEXPECTED_ERROR; str_drc_coeff_param_drc->parametric_drc_frame_size_format = temp & 1; - if (str_drc_coeff_param_drc->parametric_drc_frame_size) { + if (str_drc_coeff_param_drc->parametric_drc_frame_size_format) { code = impd_read_bits_buf(it_bit_buff, 15); if (it_bit_buff->error) return it_bit_buff->error; str_drc_coeff_param_drc->parametric_drc_frame_size = code + 1; @@ -532,6 +539,7 @@ static WORD32 impd_parametic_drc_parse_coeff( str_drc_coeff_param_drc->parametric_drc_delay_max_present = impd_read_bits_buf(it_bit_buff, 1); + if (it_bit_buff->error) return it_bit_buff->error; if (str_drc_coeff_param_drc->parametric_drc_delay_max_present) { temp = impd_read_bits_buf(it_bit_buff, 8); if (it_bit_buff->error) return it_bit_buff->error; @@ -723,6 +731,8 @@ WORD32 impd_parse_ch_layout(ia_bit_buf_struct* it_bit_buff, channel_layout->base_channel_count = impd_read_bits_buf(it_bit_buff, 7); if (it_bit_buff->error) return it_bit_buff->error; + if (channel_layout->base_channel_count > MAX_CHANNEL_COUNT) + return (UNEXPECTED_ERROR); if (ia_drc_params_struct->lfe_channel_map_count != -1 && channel_layout->base_channel_count != ia_drc_params_struct->lfe_channel_map_count) { @@ -767,6 +777,8 @@ impd_parse_dwnmix_instructions( dwnmix_instructions->downmix_id = (temp >> 16) & 0x7f; dwnmix_instructions->target_channel_count = (temp >> 9) & 0x7f; + if (dwnmix_instructions->target_channel_count > MAX_CHANNEL_COUNT) + return (UNEXPECTED_ERROR); dwnmix_instructions->target_layout = (temp >> 1) & 0xff; dwnmix_instructions->downmix_coefficients_present = temp & 1; @@ -1219,6 +1231,9 @@ impd_parse_drc_config(ia_bit_buf_struct* it_bit_buff, if (err) return (err); } + if ((drc_config->drc_instructions_uni_drc_count + + drc_config->dwnmix_instructions_count) >= DRC_INSTRUCTIONS_COUNT_MAX) + return (UNEXPECTED_ERROR); impd_drc_gen_instructions_for_drc_off(drc_config); return (0); } @@ -1440,13 +1455,15 @@ impd_dec_gain_modifiers(ia_bit_buf_struct* it_bit_buff, WORD32 version, } } if (band_count == 1) { + WORD32 tmp; pstr_gain_modifiers->shape_filter_flag = impd_read_bits_buf(it_bit_buff, 1); if (it_bit_buff->error) return it_bit_buff->error; if (pstr_gain_modifiers->shape_filter_flag) { - pstr_gain_modifiers->shape_filter_idx = - impd_read_bits_buf(it_bit_buff, 4); + tmp = impd_read_bits_buf(it_bit_buff, 4); if (it_bit_buff->error) return it_bit_buff->error; + if (tmp >= (SHAPE_FILTER_COUNT_MAX + 1)) return UNEXPECTED_ERROR; + pstr_gain_modifiers->shape_filter_idx = tmp; } } } else if (version == 0) { @@ -1663,6 +1680,9 @@ impd_drc_parse_coeff( drc_frame_size = impd_read_bits_buf(it_bit_buff, 15); if (it_bit_buff->error) return it_bit_buff->error; str_p_loc_drc_coefficients_uni_drc->drc_frame_size = drc_frame_size + 1; + if (str_p_loc_drc_coefficients_uni_drc->drc_frame_size > + MAX_DRC_FRAME_SIZE) + return UNEXPECTED_ERROR; } str_p_loc_drc_coefficients_uni_drc->drc_characteristic_left_present = 0; @@ -1695,6 +1715,10 @@ impd_drc_parse_coeff( ia_drc_params_struct->drc_frame_size / str_p_loc_drc_coefficients_uni_drc->gain_set_params[i] .time_delt_min_val; + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i] + .num_gain_max_values > + (N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX / 2 - 1)) + return (UNEXPECTED_ERROR); err = impd_init_tbls( str_p_loc_drc_coefficients_uni_drc->gain_set_params[i] .num_gain_max_values, @@ -1871,6 +1895,11 @@ impd_drc_parse_coeff( ia_drc_params_struct->drc_frame_size / str_p_loc_drc_coefficients_uni_drc->gain_set_params[i] .time_delt_min_val; + if (str_p_loc_drc_coefficients_uni_drc->gain_set_params[i] + .num_gain_max_values > + (N_DELTA_TIME_CODE_TABLE_ENTRIES_MAX / 2 - 1)) + return (UNEXPECTED_ERROR); + err = impd_init_tbls( str_p_loc_drc_coefficients_uni_drc->gain_set_params[i] .num_gain_max_values, @@ -2152,8 +2181,7 @@ impd_parse_drc_instructions_uni_drc( WORD32 bs_gain_set_idx; bs_gain_set_idx = impd_read_bits_buf(it_bit_buff, 6); if (it_bit_buff->error) return it_bit_buff->error; - if ((bs_gain_set_idx == 0) || (bs_gain_set_idx > GAIN_SET_COUNT_MAX)) - return UNEXPECTED_ERROR; + if (bs_gain_set_idx > GAIN_SET_COUNT_MAX) return UNEXPECTED_ERROR; str_drc_instruction_str->gain_set_index[c] = bs_gain_set_idx - 1; impd_dec_ducking_scaling( it_bit_buff, @@ -2257,6 +2285,7 @@ impd_parse_drc_instructions_uni_drc( (str_drc_instruction_str->drc_set_effect & EFFECT_BIT_DUCK_OTHER) ? ducking_sequence : unique_idx[g]; + if (set < 0) return UNEXPECTED_ERROR; str_drc_instruction_str->gain_set_index_for_channel_group[g] = set; str_drc_instruction_str->str_ducking_modifiers_for_channel_group[g] .ducking_scaling = unique_scaling[g]; @@ -2305,8 +2334,7 @@ impd_parse_drc_instructions_uni_drc( bs_gain_set_idx = (temp >> 1) & 0x7f; repeat_gain_set_idx = temp & 1; - if ((bs_gain_set_idx == 0) || (bs_gain_set_idx > GAIN_SET_COUNT_MAX)) - return UNEXPECTED_ERROR; + if (bs_gain_set_idx > GAIN_SET_COUNT_MAX) return UNEXPECTED_ERROR; str_drc_instruction_str->gain_set_index[c] = bs_gain_set_idx - 1; c++; @@ -2368,6 +2396,7 @@ impd_parse_drc_instructions_uni_drc( WORD32 set, band_count; set = unique_idx[g]; + if (set < 0) return UNEXPECTED_ERROR; str_drc_instruction_str->gain_set_index_for_channel_group[g] = set; if (str_p_loc_drc_coefficients_uni_drc != NULL && diff --git a/decoder/drc_src/impd_drc_tables.c b/decoder/drc_src/impd_drc_tables.c deleted file mode 100644 index b099b5e..0000000 --- a/decoder/drc_src/impd_drc_tables.c +++ /dev/null @@ -1,102 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2015 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 <stdio.h> -#include <math.h> - -#include "impd_type_def.h" -#include "impd_drc_uni_tables.h" -#include "impd_drc_uni_common.h" -#include "impd_drc_struct.h" -#include "impd_drc_filter_bank.h" -#include "impd_drc_rom.h" - -WORD32 impd_init_tbls(const WORD32 num_gain_max_values, - ia_tables_struct* str_tables) { - impd_gen_delta_time_code_tbl(num_gain_max_values, - str_tables->delta_time_code_table); - return (0); -} - -void impd_get_slope_code_tbl_and_size( - ia_slope_code_table_struct const** slope_code_tbl_entry, - WORD32* num_slope_code_tbl_entries) { - *slope_code_tbl_entry = &(slopeCodeTableEntryBySize[0]); - *num_slope_code_tbl_entries = kNumSlopeValuesTable; -} - -void impd_get_delta_gain_code_tbl( - const WORD32 gain_coding_profile, - ia_delta_gain_code_table_struct const** delta_time_code_tbl, - WORD32* num_entries) { - if (gain_coding_profile == GAIN_CODING_PROFILE_CLIPPING) { - *delta_time_code_tbl = deltaGainCodeTableProfile2BySize; - *num_entries = kNumDeltaGainValuesTableProfile2; - } else { - *delta_time_code_tbl = deltaGainCodeTableBySize; - *num_entries = kNumDeltaGainValuesTable; - } -} - -void impd_gen_delta_time_code_tbl( - const WORD32 num_gain_max_values, - ia_delta_time_code_table_entry_struct* delta_time_code_tbl_item) { - WORD32 n, k; - - WORD32 Z = 1; - while ((1 << Z) < 2 * num_gain_max_values) { - Z++; - } - - delta_time_code_tbl_item[0].size = -1; - delta_time_code_tbl_item[0].code = -1; - delta_time_code_tbl_item[0].value = -1; - - delta_time_code_tbl_item[1].size = 2; - delta_time_code_tbl_item[1].code = 0x0; - delta_time_code_tbl_item[1].value = 1; - for (n = 0; n < 4; n++) { - delta_time_code_tbl_item[n + 2].size = 4; - delta_time_code_tbl_item[n + 2].code = 0x4 + n; - delta_time_code_tbl_item[n + 2].value = n + 2; - } - for (n = 0; n < 8; n++) { - delta_time_code_tbl_item[n + 6].size = 5; - delta_time_code_tbl_item[n + 6].code = 0x10 + n; - delta_time_code_tbl_item[n + 6].value = n + 6; - } - - k = 2 * num_gain_max_values - 14 + 1; - for (n = 0; n < k; n++) { - delta_time_code_tbl_item[n + 14].size = 2 + Z; - delta_time_code_tbl_item[n + 14].code = (0x3 << Z) + n; - delta_time_code_tbl_item[n + 14].value = n + 14; - } -} - -WORD32 -impd_get_delta_tmin(const WORD32 sampling_rate) { - WORD32 lowerBound = (WORD32)(0.5f + 0.0005f * sampling_rate); - WORD32 result = 1; - if (sampling_rate < 1000) { - return (UNEXPECTED_ERROR); - } - while (result <= lowerBound) result = result << 1; - return result; -} diff --git a/decoder/drc_src/impd_drc_uni_common.h b/decoder/drc_src/impd_drc_uni_common.h deleted file mode 100644 index f661405..0000000 --- a/decoder/drc_src/impd_drc_uni_common.h +++ /dev/null @@ -1,162 +0,0 @@ -/****************************************************************************** - * - * Copyright (C) 2015 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 -*/ -#ifndef IMPD_DRC_UNI_COMMON_H -#define IMPD_DRC_UNI_COMMON_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define AMD1_SYNTAX 0 -#define MPEG_D_DRC_EXTENSION_V1 0 -#define AMD1_PARAMETRIC_LIMITER 0 - -#define MPEG_H_SYNTAX 0 - -#define EQ_IS_SUPPORTED 1 - -#define MEASURE_AVERAGE_BITRATE 0 -#define DEBUG_NODES 0 - -#define DRC_GAIN_DEBUG_FILE 0 -#define DEBUG_BITSTREAM 0 -#define DEBUG_DRC_SELECTION 0 -#define DEBUG_WARNINGS 0 -#define ENABLE_ADDITIONAL_TESTS 1 - -#define SPEAKER_POS_COUNT_MAX 128 -#define DOWNMIX_COEFF_COUNT_MAX 32 * 32 -#define MAX_CHANNEL_COUNT 128 -#define BAND_COUNT_MAX 8 -#define SEQUENCE_COUNT_MAX 24 -#define GAIN_SET_COUNT_MAX SEQUENCE_COUNT_MAX -#define MEASUREMENT_COUNT_MAX 16 -#define DOWNMIX_INSTRUCTION_COUNT_MAX 16 -#define DRC_COEFF_COUNT_MAX 8 -#define DRC_INSTRUCTIONS_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) -#define LOUDNESS_INFO_COUNT_MAX (DOWNMIX_INSTRUCTION_COUNT_MAX + 20) -#define AUDIO_CODEC_FRAME_SIZE_MAX 4096 -#define DRC_CODEC_FRAME_SIZE_MAX (AUDIO_CODEC_FRAME_SIZE_MAX / 8) -#define NODE_COUNT_MAX DRC_CODEC_FRAME_SIZE_MAX -#define CHANNEL_GROUP_COUNT_MAX SEQUENCE_COUNT_MAX -#define SUB_DRC_COUNT 4 -#define SEL_DRC_COUNT 3 -#define DOWNMIX_ID_COUNT_MAX 8 -#define MAX_SIGNAL_DELAY 4500 - -#define DELAY_MODE_REGULAR_DELAY 0 -#define DELAY_MODE_LOW_DELAY 1 -#define DELAY_MODE_DEFAULT DELAY_MODE_REGULAR_DELAY - -#define FEATURE_REQUEST_COUNT_MAX 10 -#define EFFECT_TYPE_REQUEST_COUNT_MAX 10 - -#define SELECTION_CANDIDATE_COUNT_MAX 32 - -#define PROC_COMPLETE 1 -#define UNEXPECTED_ERROR 2 -#define PARAM_ERROR 3 -#define EXTERNAL_ERROR 4 -#define ERRORHANDLING 5 -#define BITSTREAM_ERROR 6 - -#define UNDEFINED_LOUDNESS_VALUE 1000.0f -#define ID_FOR_BASE_LAYOUT 0x0 -#define ID_FOR_ANY_DOWNMIX 0x7F -#define ID_FOR_NO_DRC 0x0 -#define ID_FOR_ANY_DRC 0x3F -#define ID_FOR_ANY_EQ 0x3F - -#define LOCATION_MP4_INSTREAM_UNIDRC 0x1 -#define LOCATION_MP4_DYN_RANGE_INFO 0x2 -#define LOCATION_MP4_COMPRESSION_VALUE 0x3 -#define LOCATION_SELECTED LOCATION_MP4_INSTREAM_UNIDRC - -#define AUDIO_CODEC_SUBBAND_COUNT_MAX 256 - -#define SUBBAND_DOMAIN_MODE_OFF 0 -#define SUBBAND_DOMAIN_MODE_QMF64 1 -#define SUBBAND_DOMAIN_MODE_QMF71 2 -#define SUBBAND_DOMAIN_MODE_STFT256 3 - -#define AUDIO_CODEC_SUBBAND_COUNT_QMF64 64 -#define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF64 64 -#define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF64 320 - -#define AUDIO_CODEC_SUBBAND_COUNT_QMF71 71 -#define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_QMF71 64 -#define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_QMF71 320 + 384 - -#define AUDIO_CODEC_SUBBAND_COUNT_STFT256 256 -#define AUDIO_CODEC_SUBBAND_DOWNSAMPLING_FACTOR_STFT256 256 -#define AUDIO_CODEC_SUBBAND_ANALYSE_DELAY_STFT256 256 - -#define MAX_NUM_DOWNMIX_ID_REQUESTS 15 -#define MAX_NUM_DRC_FEATURE_REQUESTS 7 -#define MAX_NUM_DRC_EFFECT_TYPE_REQUESTS 15 -#define MAX_SIGNATURE_DATA_LENGTH_PLUS_ONE 256 - -#define EXT_COUNT_MAX 2 -#define UNIDRCGAINEXT_TERM 0x0 -#define UNIDRCLOUDEXT_TERM 0x0 -#define UNIDRCCONFEXT_TERM 0x0 -#define UNIDRCINTERFACEEXT_TERM 0x0 - -#define MAXPACKETLOSSTIME 2.5f - -#define SLOPE_FACTOR_DB_TO_LINEAR 0.1151f - -#ifndef min -#define min(a, b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef max -#define max(a, b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef bool -#define bool WORD32 -#endif - -typedef struct ia_drc_sel_proc_output_struct { - FLOAT32 output_peak_level_db; - FLOAT32 loudness_normalization_gain_db; - FLOAT32 output_loudness; - - WORD32 sel_drc_set_ids[SUB_DRC_COUNT]; - WORD32 sel_downmix_ids[SUB_DRC_COUNT]; - WORD32 num_sel_drc_sets; - - WORD32 active_downmix_id; - WORD32 base_channel_count; - WORD32 target_channel_count; - WORD32 target_layout; - WORD32 downmix_matrix_present; - FLOAT32 downmix_matrix[MAX_CHANNEL_COUNT][MAX_CHANNEL_COUNT]; - - FLOAT32 boost; - FLOAT32 compress; - WORD32 drc_characteristic_target; - -} ia_drc_sel_proc_output_struct; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/decoder/generic/ixheaacd_function_selector_generic.c b/decoder/generic/ixheaacd_function_selector_generic.c index 08aac1b..b6c34a5 100644 --- a/decoder/generic/ixheaacd_function_selector_generic.c +++ b/decoder/generic/ixheaacd_function_selector_generic.c @@ -20,15 +20,15 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_sbrdecsettings.h" @@ -37,7 +37,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_pulsedata.h" @@ -53,7 +53,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_block.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -199,11 +199,11 @@ VOID(*ixheaacd_mps_complex_fft_64) WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec; VOID(*ixheaacd_mps_synt_pre_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec; VOID(*ixheaacd_mps_synt_post_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec; VOID(*ixheaacd_calc_pre_twid) @@ -215,8 +215,9 @@ VOID(*ixheaacd_calc_post_twid) const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec; VOID(*ixheaacd_mps_synt_post_fft_twiddle) -(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; +(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; VOID(*ixheaacd_mps_synt_out_calc) (WORD32 resolution, WORD32 *out, WORD32 *state, @@ -249,4 +250,3 @@ VOID(*ixheaacd_scale_factor_process) WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_dec; #endif - diff --git a/decoder/generic/ixheaacd_qmf_dec_generic.c b/decoder/generic/ixheaacd_qmf_dec_generic.c index 4b5120f..85e7a5b 100644 --- a/decoder/generic/ixheaacd_qmf_dec_generic.c +++ b/decoder/generic/ixheaacd_qmf_dec_generic.c @@ -20,7 +20,7 @@ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_basic_ops32.h" @@ -41,7 +41,7 @@ #include "ixheaacd_env_extr.h" #include "ixheaacd_qmf_dec.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_env_calc.h" #include "ixheaacd_interface.h" diff --git a/decoder/ixheaacd_Windowing.c b/decoder/ixheaacd_Windowing.c index 41450a3..bf384b4 100644 --- a/decoder/ixheaacd_Windowing.c +++ b/decoder/ixheaacd_Windowing.c @@ -20,9 +20,9 @@ #include "ixheaacd_cnst.h" #include "ixheaacd_constants.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_type_def.h" +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_windows.h" diff --git a/decoder/ixheaacd_aac_config.h b/decoder/ixheaacd_aac_config.h index bfe7a39..c57db29 100644 --- a/decoder/ixheaacd_aac_config.h +++ b/decoder/ixheaacd_aac_config.h @@ -60,5 +60,6 @@ #define IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF 0x0023 #define IA_ENHAACPLUS_DEC_DRC_EFFECT_TYPE 0x0024 #define IA_ENHAACPLUS_DEC_DRC_TARGET_LOUDNESS 0x0025 +#define IA_ENHAACPLUS_DEC_CONFIG_GET_NUM_PRE_ROLL_FRAMES 0x0026 #endif /* IXHEAACD_AAC_CONFIG_H */ diff --git a/decoder/ixheaacd_aac_imdct.c b/decoder/ixheaacd_aac_imdct.c index 88b23eb..43f2025 100644 --- a/decoder/ixheaacd_aac_imdct.c +++ b/decoder/ixheaacd_aac_imdct.c @@ -18,22 +18,22 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_intrinsics.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_function_selector.h" #include "ixheaacd_audioobjtypes.h" @@ -2008,14 +2008,14 @@ VOID ixheaacd_fft32x32_ld_dec(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, x_h2_0 = x[h2]; x_h2_1 = x[h2 + 1]; - xh0_0 = x_0 + x_l1_0; - xh1_0 = x_1 + x_l1_1; - xl0_0 = x_0 - x_l1_0; - xl1_0 = x_1 - x_l1_1; - xh20_0 = x_h2_0 + x_l2_0; - xh21_0 = x_h2_1 + x_l2_1; - xl20_0 = x_h2_0 - x_l2_0; - xl21_0 = x_h2_1 - x_l2_1; + xh0_0 = ixheaacd_add32_sat(x_0, x_l1_0); + xh1_0 = ixheaacd_add32_sat(x_1, x_l1_1); + xl0_0 = ixheaacd_sub32_sat(x_0, x_l1_0); + xl1_0 = ixheaacd_sub32_sat(x_1, x_l1_1); + xh20_0 = ixheaacd_add32_sat(x_h2_0, x_l2_0); + xh21_0 = ixheaacd_add32_sat(x_h2_1, x_l2_1); + xl20_0 = ixheaacd_sub32_sat(x_h2_0, x_l2_0); + xl21_0 = ixheaacd_sub32_sat(x_h2_1, x_l2_1); x0 = x; x2 = x0; @@ -2026,14 +2026,14 @@ VOID ixheaacd_fft32x32_ld_dec(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, if (!predj) x += fft_jmp; if (!predj) j = 0; - x0[0] = xh0_0 + xh20_0; - x0[1] = xh1_0 + xh21_0; - xt0_0 = xh0_0 - xh20_0; - yt0_0 = xh1_0 - xh21_0; - xt1_0 = xl0_0 + xl21_0; - yt2_0 = xl1_0 + xl20_0; - xt2_0 = xl0_0 - xl21_0; - yt1_0 = xl1_0 - xl20_0; + x0[0] = ixheaacd_add32_sat(xh0_0, xh20_0); + x0[1] = ixheaacd_add32_sat(xh1_0, xh21_0); + xt0_0 = ixheaacd_sub32_sat(xh0_0, xh20_0); + yt0_0 = ixheaacd_sub32_sat(xh1_0, xh21_0); + xt1_0 = ixheaacd_add32_sat(xl0_0, xl21_0); + yt2_0 = ixheaacd_add32_sat(xl1_0, xl20_0); + xt2_0 = ixheaacd_sub32_sat(xl0_0, xl21_0); + yt1_0 = ixheaacd_sub32_sat(xl1_0, xl20_0); x2[h2] = MPYHIRC(si10, yt1_0) + MPYHIRC(co10, xt1_0) + @@ -2095,33 +2095,33 @@ VOID ixheaacd_fft32x32_ld_dec(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, x_7 = x0[7]; x0 += 8; - xh0_0 = x_0 + x_4; - xh1_0 = x_1 + x_5; - xl0_0 = x_0 - x_4; - xl1_0 = x_1 - x_5; - xh0_1 = x_2 + x_6; - xh1_1 = x_3 + x_7; - xl0_1 = x_2 - x_6; - xl1_1 = x_3 - x_7; - - n00 = xh0_0 + xh0_1; - n01 = xh1_0 + xh1_1; - n10 = xl0_0 + xl1_1; - n11 = xl1_0 - xl0_1; - n20 = xh0_0 - xh0_1; - n21 = xh1_0 - xh1_1; - n30 = xl0_0 - xl1_1; - n31 = xl1_0 + xl0_1; + xh0_0 = ixheaacd_add32_sat(x_0, x_4); + xh1_0 = ixheaacd_add32_sat(x_1, x_5); + xl0_0 = ixheaacd_sub32_sat(x_0, x_4); + xl1_0 = ixheaacd_sub32_sat(x_1, x_5); + xh0_1 = ixheaacd_add32_sat(x_2, x_6); + xh1_1 = ixheaacd_add32_sat(x_3, x_7); + xl0_1 = ixheaacd_sub32_sat(x_2, x_6); + xl1_1 = ixheaacd_sub32_sat(x_3, x_7); + + n00 = ixheaacd_add32_sat(xh0_0, xh0_1); + n01 = ixheaacd_add32_sat(xh1_0, xh1_1); + n10 = ixheaacd_add32_sat(xl0_0, xl1_1); + n11 = ixheaacd_sub32_sat(xl1_0, xl0_1); + n20 = ixheaacd_sub32_sat(xh0_0, xh0_1); + n21 = ixheaacd_sub32_sat(xh1_0, xh1_1); + n30 = ixheaacd_sub32_sat(xl0_0, xl1_1); + n31 = ixheaacd_add32_sat(xl1_0, xl0_1); if (radix == 2) { - n00 = x_0 + x_2; - n01 = x_1 + x_3; - n20 = x_0 - x_2; - n21 = x_1 - x_3; - n10 = x_4 + x_6; - n11 = x_5 + x_7; - n30 = x_4 - x_6; - n31 = x_5 - x_7; + n00 = ixheaacd_add32_sat(x_0, x_2); + n01 = ixheaacd_add32_sat(x_1, x_3); + n20 = ixheaacd_sub32_sat(x_0, x_2); + n21 = ixheaacd_sub32_sat(x_1, x_3); + n10 = ixheaacd_add32_sat(x_4, x_6); + n11 = ixheaacd_add32_sat(x_5, x_7); + n30 = ixheaacd_sub32_sat(x_4, x_6); + n31 = ixheaacd_sub32_sat(x_5, x_7); } y0[2 * h2] = n00; @@ -2143,33 +2143,33 @@ VOID ixheaacd_fft32x32_ld_dec(ia_aac_dec_imdct_tables_struct *imdct_tables_ptr, x_f = x2[7]; x2 += 8; - xh0_2 = x_8 + x_c; - xh1_2 = x_9 + x_d; - xl0_2 = x_8 - x_c; - xl1_2 = x_9 - x_d; - xh0_3 = x_a + x_e; - xh1_3 = x_b + x_f; - xl0_3 = x_a - x_e; - xl1_3 = x_b - x_f; - - n02 = xh0_2 + xh0_3; - n03 = xh1_2 + xh1_3; - n12 = xl0_2 + xl1_3; - n13 = xl1_2 - xl0_3; - n22 = xh0_2 - xh0_3; - n23 = xh1_2 - xh1_3; - n32 = xl0_2 - xl1_3; - n33 = xl1_2 + xl0_3; + xh0_2 = ixheaacd_add32_sat(x_8, x_c); + xh1_2 = ixheaacd_add32_sat(x_9, x_d); + xl0_2 = ixheaacd_sub32_sat(x_8, x_c); + xl1_2 = ixheaacd_sub32_sat(x_9, x_d); + xh0_3 = ixheaacd_add32_sat(x_a, x_e); + xh1_3 = ixheaacd_add32_sat(x_b, x_f); + xl0_3 = ixheaacd_sub32_sat(x_a, x_e); + xl1_3 = ixheaacd_sub32_sat(x_b, x_f); + + n02 = ixheaacd_add32_sat(xh0_2, xh0_3); + n03 = ixheaacd_add32_sat(xh1_2, xh1_3); + n12 = ixheaacd_add32_sat(xl0_2, xl1_3); + n13 = ixheaacd_sub32_sat(xl1_2, xl0_3); + n22 = ixheaacd_sub32_sat(xh0_2, xh0_3); + n23 = ixheaacd_sub32_sat(xh1_2, xh1_3); + n32 = ixheaacd_sub32_sat(xl0_2, xl1_3); + n33 = ixheaacd_add32_sat(xl1_2, xl0_3); if (radix == 2) { - n02 = x_8 + x_a; - n03 = x_9 + x_b; - n22 = x_8 - x_a; - n23 = x_9 - x_b; - n12 = x_c + x_e; - n13 = x_d + x_f; - n32 = x_c - x_e; - n33 = x_d - x_f; + n02 = ixheaacd_add32_sat(x_8, x_a); + n03 = ixheaacd_add32_sat(x_9, x_b); + n22 = ixheaacd_sub32_sat(x_8, x_a); + n23 = ixheaacd_sub32_sat(x_9, x_b); + n12 = ixheaacd_add32_sat(x_c, x_e); + n13 = ixheaacd_add32_sat(x_d, x_f); + n32 = ixheaacd_sub32_sat(x_c, x_e); + n33 = ixheaacd_sub32_sat(x_d, x_f); } y0[2 * h2 + 2] = n02; diff --git a/decoder/ixheaacd_aac_rom.c b/decoder/ixheaacd_aac_rom.c index ca52137..8c3d426 100644 --- a/decoder/ixheaacd_aac_rom.c +++ b/decoder/ixheaacd_aac_rom.c @@ -18,9 +18,9 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_intrinsics.h" // -1 is appended at the end of each table to identify diff --git a/decoder/ixheaacd_aac_tns.c b/decoder/ixheaacd_aac_tns.c index 3fbaf9a..641fdc7 100644 --- a/decoder/ixheaacd_aac_tns.c +++ b/decoder/ixheaacd_aac_tns.c @@ -18,19 +18,19 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_error_codes.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -63,15 +63,6 @@ static PLATFORM_INLINE WORD32 ixheaacd_mac32_tns_sat(WORD32 a, WORD32 b, return (result); } -static PLATFORM_INLINE WORD64 mac32x32in64_dual(WORD32 a, WORD32 b, WORD64 c) { - WORD64 result; - WORD64 temp_result; - - temp_result = (WORD64)a * (WORD64)b; - result = c + (temp_result); - return (result); -} - VOID ixheaacd_tns_decode_coefficients( const ia_filter_info_struct *filter, WORD32 *a, ia_aac_dec_tables_struct *ptr_aac_tables) { @@ -294,7 +285,7 @@ VOID ixheaacd_tns_ar_filter_fixed_non_neon_armv7(WORD32 *spectrum, WORD32 size, WORD32 acc1; y = ixheaacd_shl32_sat((*spectrum), scale_spec); for (j = order; j > 0; j--) { - acc = mac32x32in64_dual(state[j - 1], lpc[j], acc); + acc = ixheaacd_mac32x32in64_dual(state[j - 1], lpc[j], acc); state[j] = state[j - 1]; } acc1 = (WORD32)(acc >> 32); @@ -349,7 +340,7 @@ VOID ixheaacd_tns_ar_filter_fixed_armv8(WORD32 *spectrum, WORD32 size, } acc1 = (WORD32)(acc >> 32); - y = ixheaacd_sub32(y, ixheaacd_shl32_sat(acc1, 1)); + y = ixheaacd_sub32_sat(y, ixheaacd_shl32_sat(acc1, 1)); state[0] = ixheaacd_shl32_sat(y, shift_value); *spectrum = y >> scale_spec; @@ -387,11 +378,15 @@ VOID ixheaacd_tns_ar_filter_dec(WORD32 *spectrum, WORD32 size, WORD32 inc, WORD32 acc; if ((order & 3) != 0) { - for (i = order + 1; i < ((WORD32)(order & 0xfffffffc) + 4); i++) { + for (i = order + 1; i < ((WORD32)(order & (~3)) + 4); i++) { lpc[i] = 0; } - lpc[i] = 0; - order = ((order & 0xfffffffc) + 4); + if (i < (MAX_ORDER + 1)) { + lpc[i] = 0; + order = ((order & (~3)) + 4); + } else { + order = MAX_ORDER; + } } for (i = 0; i < order; i++) { diff --git a/decoder/ixheaacd_aacdecoder.c b/decoder/ixheaacd_aacdecoder.c index 19770ad..15dc4bb 100644 --- a/decoder/ixheaacd_aacdecoder.c +++ b/decoder/ixheaacd_aacdecoder.c @@ -20,21 +20,21 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_bitbuffer.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_definitions.h" @@ -56,13 +56,10 @@ #include "ixheaacd_sbr_payload.h" #include "ixheaacd_common_rom.h" - -#include <ixheaacd_type_def.h> - #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_stereo.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_hybrid.h" diff --git a/decoder/ixheaacd_aacpluscheck.c b/decoder/ixheaacd_aacpluscheck.c index 15d74c3..3029335 100644 --- a/decoder/ixheaacd_aacpluscheck.c +++ b/decoder/ixheaacd_aacpluscheck.c @@ -20,22 +20,22 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_defines.h" #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -158,7 +158,6 @@ FLAG ixheaacd_check_for_sbr_payload( } it_bit_buff->ptr_read_next += count - 1; it_bit_buff->cnt_bits -= ((count - 1) << 3); - } } if (it_bit_buff->cnt_bits < 0) ret = -1; diff --git a/decoder/ixheaacd_acelp_bitparse.c b/decoder/ixheaacd_acelp_bitparse.c index 17f669b..aee2ea8 100644 --- a/decoder/ixheaacd_acelp_bitparse.c +++ b/decoder/ixheaacd_acelp_bitparse.c @@ -20,7 +20,7 @@ #include <math.h> #include <stdio.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_acelp_com.h" #include "ixheaacd_windows.h" @@ -48,9 +48,8 @@ #include "ixheaacd_main.h" #include "ixheaacd_func_def.h" #include "ixheaacd_constants.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" WORD32 ixheaacd_get_mode_lpc(WORD32 lpc_set, ia_bit_buf_struct *it_bit_buff, WORD32 *nk_mode) { @@ -264,7 +263,7 @@ VOID ixheaacd_fac_decoding(WORD32 fac_length, WORD32 k, WORD32 *fac_prm, } } -UWORD8 ixheaacd_num_bites_celp_coding[8][4] = { +const UWORD8 ixheaacd_num_bites_celp_coding[8][4] = { {5, 5, 5, 5}, {9, 9, 5, 5}, {9, 9, 9, 9}, {13, 13, 9, 9}, {13, 13, 13, 13}, {16, 16, 16, 16}, {1, 5, 1, 5}, {1, 5, 5, 5}}; @@ -273,7 +272,7 @@ VOID ixheaacd_acelp_decoding(WORD32 k, ia_usac_data_struct *usac_data, ia_bit_buf_struct *it_bit_buff, WORD32 chan) { WORD32 sfr, kk; WORD32 nb_subfr = usac_data->num_subfrm; - UWORD8 *ptr_num_bits = + const UWORD8 *ptr_num_bits = &ixheaacd_num_bites_celp_coding[pstr_td_frame_data->acelp_core_mode][0]; chan = 0; @@ -557,4 +556,4 @@ VOID ixheaacd_td_frm_dec(ia_usac_data_struct *usac_data, WORD32 k, p_ioverlap[i] = 0; } } -}
\ No newline at end of file +} diff --git a/decoder/ixheaacd_acelp_com.h b/decoder/ixheaacd_acelp_com.h index 363f25f..6b12afe 100644 --- a/decoder/ixheaacd_acelp_com.h +++ b/decoder/ixheaacd_acelp_com.h @@ -62,7 +62,7 @@ VOID ixheaacd_lpc_coeff_wt_apply(FLOAT32 *a, FLOAT32 *ap); VOID ixheaacd_acelp_pitch_sharpening(FLOAT32 *x, WORD32 pit_lag); -VOID ixheaacd_acelp_decode_pulses_per_track(WORD32 index[], WORD16 nbbits, +VOID ixheaacd_acelp_decode_pulses_per_track(WORD32 index[], const WORD16 nbbits, FLOAT32 code[]); #endif diff --git a/decoder/ixheaacd_acelp_decode.c b/decoder/ixheaacd_acelp_decode.c index 73a7c9f..e209a33 100644 --- a/decoder/ixheaacd_acelp_decode.c +++ b/decoder/ixheaacd_acelp_decode.c @@ -23,7 +23,7 @@ #include <math.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" @@ -218,7 +218,8 @@ static VOID ixheaacd_d_acelp_decode_1p_n1(WORD32 index, WORD32 N, return; } -VOID ixheaacd_acelp_decode_pulses_per_track(WORD32 cb_index[], WORD16 code_bits, +VOID ixheaacd_acelp_decode_pulses_per_track(WORD32 cb_index[], + const WORD16 code_bits, FLOAT32 code_vec[]) { WORD32 track_idx, index, ixheaacd_drc_offset, pos[6], i; memset(code_vec, 0, 64 * sizeof(FLOAT32)); @@ -349,8 +350,8 @@ WORD32 ixheaacd_acelp_alias_cnx(ia_usac_data_struct *usac_data, FLOAT32 tmp, pitch_gain, gain_code, voicing_factor, r_v, innov_energy, pitch_energy, mean_ener_code; FLOAT32 gain_smooth, gain_code0, cpe; - FLOAT32 code[LEN_SUBFR], synth_temp[128 + 16]; - FLOAT32 post_process_exc[LEN_SUBFR]; + FLOAT32 code[LEN_SUBFR] = {0}, synth_temp[128 + 16] = {0}; + FLOAT32 post_process_exc[LEN_SUBFR] = {0}; FLOAT32 gain_smooth_factor; FLOAT32 *ptr_lp_filt_coeff; WORD32 pitch_min; @@ -358,9 +359,9 @@ WORD32 ixheaacd_acelp_alias_cnx(ia_usac_data_struct *usac_data, WORD32 pitch_fr1; WORD32 pitch_max; WORD32 subfr_nb = 0; - WORD16 num_codebits_table[8] = {20, 28, 36, 44, 52, 64, 12, 16}; - FLOAT32 x[FAC_LENGTH], xn2[2 * FAC_LENGTH + 16]; - WORD32 int_x[FAC_LENGTH]; + static const WORD16 num_codebits_table[8] = {20, 28, 36, 44, 52, 64, 12, 16}; + FLOAT32 x[FAC_LENGTH] = {0}, xn2[2 * FAC_LENGTH + 16] = {0}; + WORD32 int_x[FAC_LENGTH] = {0}; WORD32 TTT; WORD32 len_subfr = usac_data->len_subfrm; WORD32 fac_length; diff --git a/decoder/ixheaacd_acelp_mdct.c b/decoder/ixheaacd_acelp_mdct.c index 63713cd..777bf15 100644 --- a/decoder/ixheaacd_acelp_mdct.c +++ b/decoder/ixheaacd_acelp_mdct.c @@ -20,7 +20,7 @@ #include <stdlib.h> #include <math.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" @@ -46,9 +46,8 @@ #include "ixheaacd_func_def.h" #include "ixheaacd_constants.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" extern const WORD32 ixheaacd_pre_post_twid_cos_sin_512[4][512]; extern const WORD32 ixheaacd_pre_post_twid_cos_sin_384[4][384]; diff --git a/decoder/ixheaacd_acelp_tools.c b/decoder/ixheaacd_acelp_tools.c index 430b6f4..b3d752f 100644 --- a/decoder/ixheaacd_acelp_tools.c +++ b/decoder/ixheaacd_acelp_tools.c @@ -19,14 +19,14 @@ */ #include <math.h> #include <memory.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_cnst.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" -static FLOAT32 ixheaacd_gamma_table[17] = { +static const FLOAT32 ixheaacd_gamma_table[17] = { 1.0f, 0.92f, 0.8464f, 0.778688f, 0.716393f, 0.659082f, 0.606355f, 0.557847f, 0.513219f, 0.472161f, 0.434389f, 0.399637f, 0.367666f, 0.338253f, 0.311193f, 0.286298f, 0.263394f}; diff --git a/decoder/ixheaacd_adts_crc_check.c b/decoder/ixheaacd_adts_crc_check.c index 6761a76..b908332 100644 --- a/decoder/ixheaacd_adts_crc_check.c +++ b/decoder/ixheaacd_adts_crc_check.c @@ -17,16 +17,15 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> #include "ixheaacd_bitbuffer.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_pulsedata.h" diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index 1947a24..0cdf6e7 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -20,13 +20,13 @@ #include <string.h> #include <stdio.h> #include <stdlib.h> +#include <assert.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_error_standards.h" @@ -45,12 +45,12 @@ #include "ixheaacd_bitbuffer.h" #include "ixheaacd_adts.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -440,8 +440,14 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, } case IA_CMD_TYPE_INIT_PROCESS: { WORD32 err_code = 0; - err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); + if (p_obj_exhaacplus_dec->p_state_aac->fatal_err_present) { + err_code = IA_FATAL_ERROR; + } else { + err_code = ixheaacd_dec_init(p_obj_exhaacplus_dec); + } if (err_code != 0) { + if (err_code < 0) + p_obj_exhaacplus_dec->p_state_aac->fatal_err_present = 1; p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; } @@ -701,6 +707,20 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, if (i_idx >= 0 && i_idx <= 8) { *pui_value = pvalue[i_idx]; + } else if (IA_ENHAACPLUS_DEC_CONFIG_GET_NUM_PRE_ROLL_FRAMES == i_idx) { + WORD32 *ptri_value = (WORD32 *)pv_value; + ia_audio_specific_config_struct *ptr_audio_specific_config = + ((ia_audio_specific_config_struct *) + p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); + + for (i = 0; i < MAX_AUDIO_PREROLLS + 1; i++) { + if (ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .preroll_bytes[i] == 0) { + break; + } + } + + *ptri_value = i; } else if (IA_ENHAACPLUS_DEC_CONFIG_EXT_ELE_PTR == i_idx) { ia_audio_specific_config_struct *ptr_audio_specific_config = ((ia_audio_specific_config_struct *) @@ -762,15 +782,29 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, ia_audio_specific_config_struct *ptr_audio_specific_config = ((ia_audio_specific_config_struct *) p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); - *ptri_value = ptr_audio_specific_config->str_usac_config - .str_usac_dec_config.usac_ext_gain_payload_len; + WORD32 preroll_counter = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.preroll_counter; + *ptri_value = + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len[preroll_counter]; } else if (IA_ENHAACPLUS_DEC_CONFIG_GAIN_PAYLOAD_BUF == i_idx) { + WORD32 payload_buffer_offeset = 0; ia_audio_specific_config_struct *ptr_audio_specific_config = ((ia_audio_specific_config_struct *) p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); + WORD32 preroll_counter = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.preroll_counter; + for (i = 0; i < (UWORD32)preroll_counter; i++) + payload_buffer_offeset += + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len[i] * + sizeof(WORD8); *pp_value = ptr_audio_specific_config->str_usac_config - .str_usac_dec_config.usac_ext_gain_payload_buf; - } else { + .str_usac_dec_config.usac_ext_gain_payload_buf + + payload_buffer_offeset; + } + + else { return IA_ENHAACPLUS_DEC_API_FATAL_INVALID_CONFIG_PARAM; } break; @@ -806,12 +840,15 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, switch (i_idx) { case IA_CMD_TYPE_DO_EXECUTE: { WORD32 err_code = 0; - if (!p_obj_exhaacplus_dec->p_state_aac->ui_init_done) { + if (!p_obj_exhaacplus_dec->p_state_aac->ui_init_done || + p_obj_exhaacplus_dec->p_state_aac->fatal_err_present) { err_code = IA_FATAL_ERROR; } else { err_code = ixheaacd_dec_execute(p_obj_exhaacplus_dec); } if (err_code != IA_NO_ERROR) { + if (err_code < 0) + p_obj_exhaacplus_dec->p_state_aac->fatal_err_present = 1; p_obj_exhaacplus_dec->p_state_aac->i_bytes_consumed = p_obj_exhaacplus_dec->p_state_aac->ui_in_bytes; } @@ -840,7 +877,24 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_enhaacplus_dec_obj, WORD32 i_cmd, break; } case IA_API_CMD_GET_OUTPUT_BYTES: { - *pui_value = p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes; + if (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == AOT_USAC) { + ia_audio_specific_config_struct *ptr_audio_specific_config = + ((ia_audio_specific_config_struct *) + p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); + + WORD32 preroll_counter = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.preroll_counter; + + *pui_value = ptr_audio_specific_config->str_usac_config + .str_usac_dec_config.preroll_bytes[preroll_counter]; + + preroll_counter++; + if (preroll_counter > (MAX_AUDIO_PREROLLS + 1)) return IA_FATAL_ERROR; + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .preroll_counter = preroll_counter; + } else { + *pui_value = p_obj_exhaacplus_dec->p_state_aac->ui_out_bytes; + } break; } case IA_API_CMD_INPUT_OVER: { @@ -1174,7 +1228,7 @@ IA_ERRORCODE ixheaacd_fill_aac_mem_tables( { p_mem_info_aac = &p_obj_exhaacplus_dec->p_mem_info_aac[IA_ENHAACPLUS_DEC_OUTPUT_IDX]; - p_mem_info_aac->ui_size = num_channels * IA_ENHAACPLUS_DEC_OUT_BUF_SIZE; + p_mem_info_aac->ui_size = IA_ENHAACPLUS_DEC_OUT_BUF_SIZE; p_mem_info_aac->ui_alignment = 8; p_mem_info_aac->ui_type = IA_MEMTYPE_OUTPUT; } @@ -1929,6 +1983,7 @@ IA_ERRORCODE ixheaacd_dec_init( WORD ch_idx_err = 0; WORD persistent_used_t = 0; WORD channel_check = 0; + WORD cc_channel_check = 0; WORD max_ch_num = p_obj_exhaacplus_dec->aac_config.ui_max_channels; i = 0; @@ -1953,30 +2008,34 @@ IA_ERRORCODE ixheaacd_dec_init( while (p_obj_exhaacplus_dec->aac_config.element_type[i] >= 0 && p_obj_exhaacplus_dec->aac_config.element_type[i] <= 3) { WORD32 channel = 0; - if (p_obj_exhaacplus_dec->aac_config.element_type[i] == 0 || - p_obj_exhaacplus_dec->aac_config.element_type[i] == 3) { - channel = 1; - } - - if (p_obj_exhaacplus_dec->aac_config.element_type[i] == 1) { - channel = 2; - } - - if (p_obj_exhaacplus_dec->aac_config.element_type[i] == 2) { - if (max_ch_num > 2) { - if (p_obj_exhaacplus_dec->aac_config.element_instance_order[i] != - p_obj_exhaacplus_dec->aac_config.ui_coupling_channel) { + switch (p_obj_exhaacplus_dec->aac_config.element_type[i]) { + case 0: + case 3: + channel = 1; + break; + case 1: + channel = 2; + break; + case 2: + if (max_ch_num > 2) { + if (p_obj_exhaacplus_dec->aac_config.element_instance_order[i] != + p_obj_exhaacplus_dec->aac_config.ui_coupling_channel) { + i++; + continue; + } + channel = 1; + } else { i++; continue; } - channel = 1; - } else - - { - i++; - continue; - } + cc_channel_check++; + break; + default: + assert(0); } + + if (cc_channel_check > MAX_CC_CHANNEL_NUM) + return IA_ENHAACPLUS_DEC_EXE_FATAL_UNIMPLEMENTED_CCE; if (ps_enable == 1) { channel = 2; } @@ -2034,9 +2093,19 @@ IA_ERRORCODE ixheaacd_dec_init( p_state_enhaacplus_dec->str_sbr_dec_info[i]->xaac_jmp_buf = &(p_state_enhaacplus_dec->xaac_jmp_buf); } + if (sbr_present_flag && + ((p_obj_exhaacplus_dec->p_state_aac->audio_object_type == + AOT_AAC_LC) || + (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == + AOT_SBR) || + (p_obj_exhaacplus_dec->p_state_aac->audio_object_type == AOT_PS))) + p_obj_exhaacplus_dec->aac_config.flag_to_stereo = 1; i++; } + p_state_enhaacplus_dec->pers_mem_ptr = + (WORD8 *)p_state_enhaacplus_dec->aac_persistent_mem_v + + persistent_used_t; p_obj_exhaacplus_dec->aac_config.i_channel_mask = ixheaacd_get_channel_mask(p_obj_exhaacplus_dec); @@ -2203,7 +2272,37 @@ IA_ERRORCODE ixheaacd_dec_execute( WORD32 frames_done = p_obj_exhaacplus_dec->p_state_aac->frame_counter; + ia_dec_data_struct *pstr_dec_data = + (ia_dec_data_struct *)(p_obj_exhaacplus_dec->p_state_aac + ->pstr_dec_data); + + if (pstr_dec_data->str_usac_data.down_samp_sbr != 0) return IA_FATAL_ERROR; + if (p_obj_exhaacplus_dec->p_state_aac->ui_input_over == 0) { + ia_audio_specific_config_struct *ptr_audio_specific_config = + ((ia_audio_specific_config_struct *) + p_obj_exhaacplus_dec->p_state_aac->ia_audio_specific_config); + + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .preroll_counter = 0; + { + WORD32 iii = 0; + for (iii = 0; iii < (MAX_AUDIO_PREROLLS + 1); iii++) { + ((ia_dec_data_struct *)(p_obj_exhaacplus_dec->p_state_aac + ->pstr_dec_data)) + ->str_frame_data.str_audio_specific_config.str_usac_config + .str_usac_dec_config.usac_ext_gain_payload_len[iii] = 0; + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len[iii] = + 0; // reinitilize the payload len buff + ptr_audio_specific_config->str_usac_config.str_usac_dec_config + .preroll_bytes[iii] = 0; + } + } + + ((ia_dec_data_struct *)(p_obj_exhaacplus_dec->p_state_aac->pstr_dec_data)) + ->str_frame_data.str_audio_specific_config.str_usac_config + .str_usac_dec_config.preroll_counter = 0; error_code = ixheaacd_dec_main( p_obj_exhaacplus_dec, inbuffer, outbuffer, &out_bytes, frames_done, pcm_size, &p_obj_exhaacplus_dec->p_state_aac->num_of_output_ch); @@ -2362,7 +2461,7 @@ IA_ERRORCODE ixheaacd_dec_execute( p_state_enhaacplus_dec, (ia_sampling_rate_info_struct *)&p_obj_exhaacplus_dec->aac_tables .pstr_huffmann_tables->str_sample_rate_info[0]); - if (result < 0) return result; + if (result) return result; if (!p_state_enhaacplus_dec->latm_initialized) { p_state_enhaacplus_dec->sampling_rate = p_state_enhaacplus_dec->latm_struct_element.layer_info[0][0] @@ -2446,14 +2545,12 @@ IA_ERRORCODE ixheaacd_dec_execute( WORD32 pers_used = 0; skip_full_decode = 1; pers_used = ixheaacd_set_aac_persistent_buffers( - (WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + (8 * 1024), - channel); + p_state_enhaacplus_dec->pers_mem_ptr, channel); { struct ia_aac_persistent_struct *aac_persistent_mem = - (struct ia_aac_persistent_struct - *)((WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + - (8 * 1024)); + (struct ia_aac_persistent_struct *) + p_state_enhaacplus_dec->pers_mem_ptr; aac_persistent_mem->str_aac_decoder.pstr_aac_tables = &p_obj_exhaacplus_dec->aac_tables; aac_persistent_mem->str_aac_decoder.pstr_common_tables = @@ -2470,8 +2567,7 @@ IA_ERRORCODE ixheaacd_dec_execute( p_state_enhaacplus_dec->pstr_stream_sbr[ch_idx], - channel, - (WORD8 *)p_state_enhaacplus_dec->aac_scratch_mem_v + (8 * 1024), + channel, p_state_enhaacplus_dec->pers_mem_ptr, p_state_enhaacplus_dec->frame_length ); diff --git a/decoder/ixheaacd_arith_dec.c b/decoder/ixheaacd_arith_dec.c index 14bb414..6c6069c 100644 --- a/decoder/ixheaacd_arith_dec.c +++ b/decoder/ixheaacd_arith_dec.c @@ -19,11 +19,11 @@ */ #include <math.h> #include <string.h> -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" @@ -49,10 +49,10 @@ #define ARITH_ESCAPE 16 -UWORD16 ixheaacd_ari_cf_r[3][4] = { +static const UWORD16 ixheaacd_ari_cf_r[3][4] = { {12571, 10569, 3696, 0}, {12661, 5700, 3751, 0}, {10827, 6884, 2929, 0}}; -static UWORD16 ixheaacd_ari_lookup_m[742] = { +static const UWORD16 ixheaacd_ari_lookup_m[742] = { 0x01, 0x34, 0x0D, 0x13, 0x12, 0x25, 0x00, 0x3A, 0x05, 0x00, 0x21, 0x13, 0x1F, 0x1A, 0x1D, 0x36, 0x24, 0x2B, 0x1B, 0x33, 0x37, 0x29, 0x1D, 0x33, 0x37, 0x33, 0x37, 0x33, 0x37, 0x33, 0x2C, 0x00, 0x21, 0x13, 0x25, 0x2A, @@ -116,7 +116,7 @@ static UWORD16 ixheaacd_ari_lookup_m[742] = { 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x17, 0x27, 0x15, 0x27, 0x27, 0x15, 0x27}; -static UWORD32 ixheaacd_ari_hash_m[742] = { +static const UWORD32 ixheaacd_ari_hash_m[742] = { 0x00000104UL >> 8, 0x0000030AUL >> 8, 0x00000510UL >> 8, 0x00000716UL >> 8, 0x00000A1FUL >> 8, 0x00000F2EUL >> 8, 0x00011100UL >> 8, 0x00111103UL >> 8, 0x00111306UL >> 8, 0x00111436UL >> 8, 0x00111623UL >> 8, 0x00111929UL >> 8, @@ -304,7 +304,7 @@ static UWORD32 ixheaacd_ari_hash_m[742] = { 0x06000F27UL >> 8, 0x069FFF17UL >> 8, 0x06FFFF17UL >> 8, 0x08110017UL >> 8, 0x08EFFF15UL >> 8, 0xFFFFFF00UL >> 8}; -static UWORD8 ixheaacd_ari_hash_m_1[742] = { +static const UWORD8 ixheaacd_ari_hash_m_1[742] = { (UWORD8)0x04, (UWORD8)0x0A, (UWORD8)0x10, (UWORD8)0x16, (UWORD8)0x1F, (UWORD8)0x2E, (UWORD8)0x00, (UWORD8)0x03, (UWORD8)0x06, (UWORD8)0x36, (UWORD8)0x23, (UWORD8)0x29, (UWORD8)0x2E, (UWORD8)0x1B, (UWORD8)0x35, @@ -455,7 +455,7 @@ static UWORD8 ixheaacd_ari_hash_m_1[742] = { (UWORD8)0x2F, (UWORD8)0x27, (UWORD8)0x17, (UWORD8)0x17, (UWORD8)0x17, (UWORD8)0x15, (UWORD8)0x00}; -UWORD16 ixheaacd_ari_cf_m[64][17] = { +static const UWORD16 ixheaacd_ari_cf_m[64][17] = { {708, 706, 579, 569, 568, 567, 479, 469, 297, 138, 97, 91, 72, 52, 38, 34, 0}, {7619, 6917, 6519, 6412, 5514, 5003, 4683, 4563, 3907, 3297, 3125, 3060, @@ -1625,8 +1625,8 @@ const WORD32 ixheaacd_pow_table_Q13[1025] = {0, 84441795, 84551870}; -static WORD32 ixheaacd_esc_nb_offset[8] = {0, 131072, 262144, 393216, - 524288, 655360, 786432, 917504}; +static const WORD32 ixheaacd_esc_nb_offset[8] = { + 0, 131072, 262144, 393216, 524288, 655360, 786432, 917504}; static void ixheaacd_arith_map_context(WORD32 pres_n, WORD32 prev_n, WORD8 *c_prev, WORD8 *c, @@ -1730,34 +1730,26 @@ static WORD32 ixheaacd_arith_decode(ia_bit_buf_struct *it_bit_buff, UWORD16 const *cum_freq, WORD32 cfl) { register WORD32 symbol; register WORD32 low, high, range, value; - register WORD32 cum; + register WORD32 cumulative; register UWORD16 const *p; register UWORD16 const *q; - WORD32 short_value, i = 16; - int shift_value; - if (it_bit_buff->cnt_bits < 16) { - shift_value = 16 - it_bit_buff->cnt_bits; - short_value = ixheaacd_read_bits_buf(it_bit_buff, it_bit_buff->cnt_bits); - short_value <<= shift_value; - } else { - shift_value = 0; - short_value = ixheaacd_read_bits_buf(it_bit_buff, 16); - } - low = s->low; high = s->high; value = s->value; range = high - low + 1; - cum = ((((WORD32)(value - low + 1)) << 14) - ((WORD32)1)) / ((WORD32)range); + cumulative = ((((WORD32)(value - low + 1)) << 14) - ((WORD32)1)) / ((WORD32)range); + + if (it_bit_buff->cnt_bits == 0) + if (cumulative <= 0) return -1; p = cum_freq - 1; do { q = p + (cfl >> 1); - if (*q > cum) { + if (*q > cumulative) { p = q; cfl++; } @@ -1786,12 +1778,14 @@ static WORD32 ixheaacd_arith_decode(ia_bit_buf_struct *it_bit_buff, low += low; high += high + 1; - i--; - value = (value << 1) | ((short_value >> i) & 1); + if (it_bit_buff->cnt_bits > 0) + value = (value << 1) | ixheaacd_read_bits_buf(it_bit_buff, 1); + else + value = (value << 1); + bit_count++; } - ixheaacd_read_bidirection(it_bit_buff, -(i - shift_value)); s->low = low; s->high = high; s->value = value; @@ -1847,10 +1841,6 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff, if (esc_nb > 7) { esc_nb = 7; } - if (esc_nb < 0) { - esc_nb = 0; - return -1; - } } if (m == 0) { @@ -1891,8 +1881,8 @@ WORD32 ixheaacd_arth_decoding_level2(ia_bit_buf_struct *it_bit_buff, if (bit_count > 0) { bit_count_5 = bit_count >> 5; - for (i = 0; i < bit_count_5; i++) ixheaacd_read_bits_buf(it_bit_buff, 32); - ixheaacd_read_bits_buf(it_bit_buff, bit_count & 31); + bit_count_5 = (bit_count_5 * 32) + (bit_count & 31); + ixheaacd_skip_bits_buf(it_bit_buff, bit_count_5); } for (i = 0; i < pres_n; i++) { diff --git a/decoder/ixheaacd_avq_dec.c b/decoder/ixheaacd_avq_dec.c index 15c228c..af11cef 100644 --- a/decoder/ixheaacd_avq_dec.c +++ b/decoder/ixheaacd_avq_dec.c @@ -23,10 +23,10 @@ #include <math.h> #include <assert.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_acelp_com.h" extern const WORD32 ixheaacd_factorial_7[8]; @@ -50,11 +50,12 @@ static VOID ixheaacd_nearest_neighbor_2d(WORD32 x[], WORD32 y[], WORD32 count, sum = 0; for (i = 0; i < 8; i++) { if (x[i] < 0) { - y[i] = -2 * (((WORD32)(1 - x[i])) >> 1); + y[i] = ixheaacd_negate32_sat( + ixheaacd_shl32_sat((ixheaacd_sub32_sat(1, x[i]) >> 1), 1)); } else { - y[i] = 2 * (((WORD32)(1 + x[i])) >> 1); + y[i] = ixheaacd_shl32_sat((ixheaacd_add32_sat(1, x[i]) >> 1), 1); } - sum += y[i]; + sum = ixheaacd_add32_sat(sum, y[i]); if (x[i] % 2 != 0) { if (x[i] < 0) { @@ -89,7 +90,7 @@ static VOID ixheaacd_nearest_neighbor_2d(WORD32 x[], WORD32 y[], WORD32 count, y[j] -= 2; rem_temp[j] = ixheaacd_add32_sat(rem_temp[j], (2 << count)); } else { - y[j] += 2; + y[j] = ixheaacd_add32_sat(y[j], 2); rem_temp[j] = ixheaacd_sub32_sat(rem_temp[j], (2 << count)); } } @@ -114,14 +115,14 @@ VOID ixheaacd_voronoi_search(WORD32 x[], WORD32 y[], WORD32 count, WORD32 *rem1, rem2[i] = ixheaacd_sub32_sat(rem2[i], (1 << count)); } } else { - x1[i] = x[i] - 1; + x1[i] = ixheaacd_sub32_sat(x[i], 1); } } ixheaacd_nearest_neighbor_2d(x1, y1, count, rem2); for (i = 0; i < 8; i++) { - y1[i] += 1; + y1[i] = ixheaacd_add32_sat(y1[i], 1); } e0 = e1 = 0; @@ -164,11 +165,11 @@ VOID ixheaacd_voronoi_idx_dec(WORD32 *kv, WORD32 m, WORD32 *y, WORD32 count) { y[0] = ixheaacd_add32_sat( y[0], ixheaacd_add32_sat(ixheaacd_sat64_32((WORD64)4 * (WORD64)kv[0]), sum)); - z[0] = (y[0] - 2) >> count; + z[0] = (ixheaacd_sub32_sat(y[0], 2)) >> count; if (m != 0) - rem1[0] = (y[0] - 2) % m; + rem1[0] = (ixheaacd_sub32_sat(y[0], 2)) % m; else - rem1[0] = (y[0] - 2); + rem1[0] = ixheaacd_sub32_sat(y[0], 2); memcpy(rem2, rem1, 8 * sizeof(WORD32)); @@ -177,7 +178,9 @@ VOID ixheaacd_voronoi_idx_dec(WORD32 *kv, WORD32 m, WORD32 *y, WORD32 count) { ptr1 = y; ptr2 = v; for (i = 0; i < 8; i++) { - *ptr1++ -= ixheaacd_sat64_32((WORD64)m * (WORD64)*ptr2++); + *ptr1 = ixheaacd_sub32_sat(*ptr1, + ixheaacd_sat64_32((WORD64)m * (WORD64)*ptr2++)); + ptr1++; } } @@ -306,4 +309,4 @@ VOID ixheaacd_rotated_gosset_mtx_dec(WORD32 qn, WORD32 code_book_idx, } } return; -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_avq_rom.c b/decoder/ixheaacd_avq_rom.c index af2b803..1251923 100644 --- a/decoder/ixheaacd_avq_rom.c +++ b/decoder/ixheaacd_avq_rom.c @@ -17,7 +17,7 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_acelp_com.h" #include "ixheaacd_cnst.h" @@ -402,7 +402,7 @@ const FLOAT32 ixheaacd_interpol_filt[INTER_LP_FIL_LEN] = { 0.001151f, 0.000259f, -0.000417f, -0.000618f, -0.000434f, -0.000133f, 0.000063f, 0.000098f, 0.000048f, 0.000007f, 0.000000f}; -FLOAT32 ixheaacd_weight_table_avq[16 * 256] = { +const FLOAT32 ixheaacd_weight_table_avq[16 * 256] = { 51.35722351f, 56.66270447f, 56.93847275f, 47.94641876f, 51.14369583f, 55.13227081f, 55.94912338f, 55.60356140f, 55.40005112f, 55.63003922f, 56.32114792f, 58.34404755f, 58.28456116f, 57.81193161f, 57.67873764f, diff --git a/decoder/ixheaacd_basic_funcs.c b/decoder/ixheaacd_basic_funcs.c index d684368..6df28fc 100644 --- a/decoder/ixheaacd_basic_funcs.c +++ b/decoder/ixheaacd_basic_funcs.c @@ -18,15 +18,14 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_basic_op.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" +#include "ixheaacd_basic_op.h" +#include "ixheaacd_basic_ops.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" diff --git a/decoder/ixheaacd_basic_ops.c b/decoder/ixheaacd_basic_ops.c index f36a1ae..3887210 100644 --- a/decoder/ixheaacd_basic_ops.c +++ b/decoder/ixheaacd_basic_ops.c @@ -18,11 +18,11 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> +#include "ixheaacd_basic_ops32.h" #include "ixheaacd_windows.h" static PLATFORM_INLINE WORD32 ixheaacd_mult32_sh1(WORD32 a, WORD32 b) { @@ -65,7 +65,8 @@ VOID ixheaacd_combine_fac(WORD32 *src1, WORD32 *src2, WORD32 *dest, WORD32 len, } } else { for (i = 0; i < len; i++) { - *dest = ixheaacd_add32_sat(*src1, ((*src2) << (output_q - fac_q))); + *dest = ixheaacd_add32_sat( + *src1, ixheaacd_shl32_sat((*src2), (output_q - fac_q))); dest++; src1++; src2++; @@ -86,7 +87,8 @@ WORD8 ixheaacd_windowing_long1(WORD32 *src1, WORD32 *src2, ((ixheaacd_mult32_sh1(*src1, *win_fwd)) >> (shift1 - shift2)), ixheaacd_mult32_sh1(*src2, *win_rev)); *(dest + (vlen - (2 * i)) - 1) = ixheaacd_add32_sat( - ((ixheaacd_mult32_sh1(-(*src1), *win_rev)) >> (shift1 - shift2)), + ((ixheaacd_mult32_sh1(ixheaacd_negate32_sat(*src1), *win_rev)) >> + (shift1 - shift2)), ixheaacd_mult32_sh1(*rsrc2, *win_fwd)); src1++; @@ -104,7 +106,7 @@ WORD8 ixheaacd_windowing_long1(WORD32 *src1, WORD32 *src2, ((ixheaacd_mult32_sh1(*src2, *win_rev)) >> (shift2 - shift1))); *(dest + (vlen - (2 * i)) - 1) = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-(*src1), *win_rev), + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(*src1), *win_rev), ((ixheaacd_mult32_sh1(*rsrc2, *win_fwd)) >> (shift2 - shift1))); src1++; src2++; @@ -139,10 +141,11 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls; i++) { dest[i] = ixheaacd_add32_sat( - (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1], - *win_fwd) >> + (ixheaacd_mult32_sh1( + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]), + *win_fwd) >> (shiftp - fac_q)), (*fac_data_out)); win_fwd++; @@ -152,20 +155,21 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, for (; i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3); i++) { - dest[i] = - ixheaacd_add32_sat((-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1] >> - (shiftp - fac_q)), - (*fac_data_out)); + dest[i] = ixheaacd_add32_sat( + (ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]) >> + (shiftp - fac_q)), + (*fac_data_out)); fac_data_out++; } for (; i < ixheaacd_drc_offset->n_long; i++) { - dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1] >> - (shiftp - fac_q); + dest[i] = + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]) >> + (shiftp - fac_q); } return (fac_q); } else { @@ -176,10 +180,11 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls; i++) { dest[i] = ixheaacd_add32_sat( - (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1], - *win_fwd) >> + (ixheaacd_mult32_sh1( + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]), + *win_fwd) >> (shiftp - shift_olap)), (*fac_data_out) >> (fac_q - shift_olap)); win_fwd++; @@ -189,20 +194,21 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, for (; i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3); i++) { - dest[i] = - ixheaacd_add32_sat((-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1] >> - (shiftp - shift_olap)), - (*fac_data_out) >> (fac_q - shift_olap)); + dest[i] = ixheaacd_add32_sat( + (ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]) >> + (shiftp - shift_olap)), + (*fac_data_out) >> (fac_q - shift_olap)); fac_data_out++; } for (; i < ixheaacd_drc_offset->n_long; i++) { - dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1] >> - (shiftp - shift_olap); + dest[i] = + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]) >> + (shiftp - shift_olap); } return (shift_olap); } @@ -218,10 +224,11 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls; i++) { dest[i] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1], - *win_fwd), + ixheaacd_mult32_sh1( + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]), + *win_fwd), (*fac_data_out) >> (fac_q - shiftp)); win_fwd++; fac_data_out++; @@ -230,17 +237,19 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, for (; i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3); i++) { - dest[i] = ixheaacd_add32_sat(-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1], - (*fac_data_out) >> (fac_q - shiftp)); + dest[i] = ixheaacd_add32_sat( + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]), + (*fac_data_out) >> (fac_q - shiftp)); fac_data_out++; } for (; i < ixheaacd_drc_offset->n_long; i++) { - dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1]; + dest[i] = + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]); } return (shiftp); } else { @@ -251,10 +260,11 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls; i++) { dest[i] = ixheaacd_add32_sat( - (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1], - *win_fwd) >> + (ixheaacd_mult32_sh1( + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]), + *win_fwd) >> (shiftp - shift_olap)), (*fac_data_out) >> (fac_q - shift_olap)); win_fwd++; @@ -264,20 +274,21 @@ WORD8 ixheaacd_windowing_long2(WORD32 *src1, const WORD32 *win_fwd, for (; i < ixheaacd_drc_offset->n_flat_ls + (ixheaacd_drc_offset->lfac * 3); i++) { - dest[i] = - ixheaacd_add32_sat((-src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1] >> - (shiftp - shift_olap)), - (*fac_data_out) >> (fac_q - shift_olap)); + dest[i] = ixheaacd_add32_sat( + (ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]) >> + (shiftp - shift_olap)), + (*fac_data_out) >> (fac_q - shift_olap)); fac_data_out++; } for (; i < ixheaacd_drc_offset->n_long; i++) { - dest[i] = -src1[ixheaacd_drc_offset->n_long / 2 + - ixheaacd_drc_offset->n_flat_ls + - ixheaacd_drc_offset->lfac - i - 1] >> - (shiftp - shift_olap); + dest[i] = + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long / 2 + + ixheaacd_drc_offset->n_flat_ls + + ixheaacd_drc_offset->lfac - i - 1]) >> + (shiftp - shift_olap); } return (shift_olap); } @@ -308,8 +319,9 @@ WORD8 ixheaacd_windowing_long3(WORD32 *src1, const WORD32 *win_fwd, i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls; i++) { dest[i] = ixheaacd_add32_sat( - (ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long - i - 1], - *win_fwd) >> + (ixheaacd_mult32_sh1( + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long - i - 1]), + *win_fwd) >> (shiftp - shift_olap)), ixheaacd_mult32_sh1(over_lap[i], *win_rev)); win_fwd++; @@ -318,7 +330,8 @@ WORD8 ixheaacd_windowing_long3(WORD32 *src1, const WORD32 *win_fwd, for (; i < ixheaacd_drc_offset->n_long; i++) { dest[i] = - -src1[ixheaacd_drc_offset->n_long - i - 1] >> (shiftp - shift_olap); + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long - i - 1]) >> + (shiftp - shift_olap); } return (shift_olap); @@ -340,15 +353,17 @@ WORD8 ixheaacd_windowing_long3(WORD32 *src1, const WORD32 *win_fwd, i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->n_trans_ls; i++) { dest[i] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[ixheaacd_drc_offset->n_long - i - 1], - *win_fwd), + ixheaacd_mult32_sh1( + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long - i - 1]), + *win_fwd), ixheaacd_mult32_sh1(over_lap[i], *win_rev) >> (shift_olap - shiftp)); win_fwd++; win_rev--; } for (; i < ixheaacd_drc_offset->n_long; i++) { - dest[i] = -src1[ixheaacd_drc_offset->n_long - i - 1]; + dest[i] = + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_long - i - 1]); } return (shiftp); @@ -369,7 +384,8 @@ VOID ixheaacd_windowing_short1(WORD32 *src1, WORD32 *src2, WORD32 *fp, for (i = ixheaacd_drc_offset->lfac; i < ixheaacd_drc_offset->n_short; i++) { dest[i] = ixheaacd_mult32_sh1( - -src1[ixheaacd_drc_offset->n_short - i - 1], src2[i]); + ixheaacd_negate32_sat(src1[ixheaacd_drc_offset->n_short - i - 1]), + src2[i]); } for (; i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; @@ -390,9 +406,11 @@ VOID ixheaacd_windowing_short1(WORD32 *src1, WORD32 *src2, WORD32 *fp, if (ixheaacd_drc_offset->n_short > ixheaacd_drc_offset->lfac) { for (i = ixheaacd_drc_offset->lfac; i < ixheaacd_drc_offset->n_short; i++) { - dest[i] = ixheaacd_mult32_sh1( - -src1[ixheaacd_drc_offset->n_short - i - 1], src2[i]) >> - (shiftp - shift_olap); + dest[i] = + ixheaacd_mult32_sh1(ixheaacd_negate32_sat( + src1[ixheaacd_drc_offset->n_short - i - 1]), + src2[i]) >> + (shiftp - shift_olap); } for (; i < ixheaacd_drc_offset->n_flat_ls + ixheaacd_drc_offset->lfac; @@ -423,7 +441,7 @@ VOID ixheaacd_windowing_short2(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, (ixheaacd_mult32_sh1(fp[i], *win_rev) >> (shift_olap - shiftp))); fp[ixheaacd_drc_offset->n_short - i - 1] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[i], *win_rev), + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[i]), *win_rev), (ixheaacd_mult32_sh1(fp[ixheaacd_drc_offset->n_short - i - 1], *win_fwd) >> (shift_olap - shiftp))); @@ -443,7 +461,8 @@ VOID ixheaacd_windowing_short2(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, ixheaacd_mult32_sh1(fp[i], *win_rev)); fp[ixheaacd_drc_offset->n_short - i - 1] = ixheaacd_add32_sat( - (ixheaacd_mult32_sh1(-src1[i], *win_rev) >> (shiftp - shift_olap)), + (ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[i]), *win_rev) >> + (shiftp - shift_olap)), ixheaacd_mult32_sh1(fp[ixheaacd_drc_offset->n_short - i - 1], *win_fwd)); @@ -467,11 +486,13 @@ WORD8 ixheaacd_windowing_short3(WORD32 *src1, WORD32 *win_rev, WORD32 *fp, if (shift_olap > shiftp) { for (i = 0; i < n_short / 2; i++) { fp[i] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_rev), + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short / 2 - i - 1]), + *win_rev), (fp[i] >> (shift_olap - shiftp))); fp[n_short - i - 1] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_fwd), + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short / 2 - i - 1]), + *win_fwd), (fp[n_short - i - 1] >> (shift_olap - shiftp))); win_rev--; win_fwd++; @@ -480,12 +501,14 @@ WORD8 ixheaacd_windowing_short3(WORD32 *src1, WORD32 *win_rev, WORD32 *fp, } else { for (i = 0; i < n_short / 2; i++) { fp[i] = ixheaacd_add32_sat( - (ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_rev) >> + (ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short / 2 - i - 1]), + *win_rev) >> (shiftp - shift_olap)), fp[i]); fp[n_short - i - 1] = ixheaacd_add32_sat( - (ixheaacd_mult32_sh1(-src1[n_short / 2 - i - 1], *win_fwd) >> + (ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short / 2 - i - 1]), + *win_fwd) >> (shiftp - shift_olap)), fp[n_short - i - 1]); @@ -511,7 +534,8 @@ WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, fp[i]); fp[n_short - i - 1] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short / 2 + i], *win_rev) >> + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short / 2 + i]), + *win_rev) >> (shiftp - output_q), fp[n_short - i - 1]); @@ -521,12 +545,14 @@ WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, if (flag == 1) { for (; i < n_short; i++) { fp[i + n_short / 2] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_fwd1) >> + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short - i - 1]), + *win_fwd1) >> (shiftp - output_q), (fp[i + n_short / 2] >> (shift_olap - output_q))); fp[3 * n_short - n_short / 2 - i - 1] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_rev1) >> + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short - i - 1]), + *win_rev1) >> (shiftp - output_q), (fp[3 * n_short - n_short / 2 - i - 1] >> (shift_olap - output_q))); @@ -535,11 +561,11 @@ WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, } } else { for (; i < n_short; i++) { - fp[i + n_short / 2] = - ixheaacd_add32_sat(-src1[n_short - i - 1] >> (shiftp - output_q), - fp[i + n_short / 2] >> (shift_olap - output_q)); + fp[i + n_short / 2] = ixheaacd_add32_sat( + ixheaacd_negate32_sat(src1[n_short - i - 1]) >> (shiftp - output_q), + fp[i + n_short / 2] >> (shift_olap - output_q)); fp[3 * n_short - n_short / 2 - i - 1] = ixheaacd_add32_sat( - -src1[n_short - i - 1] >> (shiftp - output_q), + ixheaacd_negate32_sat(src1[n_short - i - 1]) >> (shiftp - output_q), fp[3 * n_short - n_short / 2 - i - 1] >> (shift_olap - output_q)); } } @@ -552,7 +578,8 @@ WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, fp[i] >> (output_q - shift_olap)); fp[n_short - i - 1] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short / 2 + i], *win_rev) >> + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short / 2 + i]), + *win_rev) >> (shiftp - shift_olap), fp[n_short - i - 1]); @@ -562,12 +589,14 @@ WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, if (flag == 1) { for (; i < n_short; i++) { fp[i + n_short / 2] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_fwd1) >> + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short - i - 1]), + *win_fwd1) >> (shiftp - shift_olap), fp[i + n_short / 2]); fp[3 * n_short - n_short / 2 - i - 1] = ixheaacd_add32_sat( - ixheaacd_mult32_sh1(-src1[n_short - i - 1], *win_rev1) >> + ixheaacd_mult32_sh1(ixheaacd_negate32_sat(src1[n_short - i - 1]), + *win_rev1) >> (shiftp - shift_olap), fp[3 * n_short - n_short / 2 - i - 1]); @@ -577,10 +606,12 @@ WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, } else { for (; i < n_short; i++) { fp[i + n_short / 2] = - ixheaacd_add32_sat(-src1[n_short - i - 1] >> (shiftp - shift_olap), + ixheaacd_add32_sat(ixheaacd_negate32_sat(src1[n_short - i - 1]) >> + (shiftp - shift_olap), fp[i + n_short / 2]); fp[3 * n_short - n_short / 2 - i - 1] = - ixheaacd_add32_sat(-src1[n_short - i - 1] >> (shiftp - shift_olap), + ixheaacd_add32_sat(ixheaacd_negate32_sat(src1[n_short - i - 1]) >> + (shiftp - shift_olap), fp[3 * n_short - n_short / 2 - i - 1]); } } @@ -599,7 +630,26 @@ VOID ixheaacd_scale_down(WORD32 *dest, WORD32 *src, WORD32 len, WORD8 shift1, } } else { for (i = 0; i < len; i++) { - *dest = *src << (shift2 - shift1); + *dest = ixheaacd_shl32_sat((*src), (shift2 - shift1)); + src++; + dest++; + } + } +} + +VOID ixheaacd_scale_down_adj(WORD32 *dest, WORD32 *src, WORD32 len, + WORD8 shift1, WORD8 shift2) { + WORD32 i; + if (shift1 > shift2) { + for (i = 0; i < len; i++) { + *dest = ixheaacd_add32_sat((*src >> (shift1 - shift2)), ADJ_SCALE); + src++; + dest++; + } + } else { + for (i = 0; i < len; i++) { + *dest = ixheaacd_add32_sat(ixheaacd_shl32_sat((*src), (shift2 - shift1)), + ADJ_SCALE); src++; dest++; } diff --git a/decoder/ixheaacd_basic_ops.h b/decoder/ixheaacd_basic_ops.h index 602ddd5..e22538b 100644 --- a/decoder/ixheaacd_basic_ops.h +++ b/decoder/ixheaacd_basic_ops.h @@ -130,7 +130,7 @@ static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_dual(WORD32 a, WORD32 b, WORD64 temp_result; temp_result = (WORD64)a * (WORD64)b; - result = c + (temp_result); + result = ixheaacd_add64_sat(c, temp_result); return (result); } diff --git a/decoder/ixheaacd_basic_ops32.h b/decoder/ixheaacd_basic_ops32.h index f9a5299..365bfbe 100644 --- a/decoder/ixheaacd_basic_ops32.h +++ b/decoder/ixheaacd_basic_ops32.h @@ -180,11 +180,8 @@ static PLATFORM_INLINE WORD32 ixheaacd_add32_sat(WORD32 a, WORD32 b) { sum = (WORD64)a + (WORD64)b; - if ((((WORD32)a ^ (WORD32)b) & (WORD32)MIN_32) == 0) { - if (((WORD32)sum ^ (WORD32)a) & (WORD32)MIN_32) { - sum = (a < 0) ? MIN_32 : MAX_32; - } - } + if (sum >= MAX_32) return MAX_32; + if (sum <= MIN_32) return MIN_32; return (WORD32)sum; } @@ -212,11 +209,8 @@ static PLATFORM_INLINE WORD32 ixheaacd_sub32_sat(WORD32 a, WORD32 b) { diff = (WORD64)a - (WORD64)b; - if ((((WORD32)a ^ (WORD32)b) & (WORD32)MIN_32) != 0) { - if (((WORD32)diff ^ (WORD32)a) & (WORD32)MIN_32) { - diff = (a < 0L) ? MIN_32 : MAX_32; - } - } + if (diff >= MAX_32) return MAX_32; + if (diff <= MIN_32) return MIN_32; return (WORD32)diff; } diff --git a/decoder/ixheaacd_basic_ops40.h b/decoder/ixheaacd_basic_ops40.h index 8f11089..06fbbb2 100644 --- a/decoder/ixheaacd_basic_ops40.h +++ b/decoder/ixheaacd_basic_ops40.h @@ -293,9 +293,9 @@ static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64(WORD64 sum, WORD32 a, return (sum); } -static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_7(WORD64 sum, - const WORD32 *a, +static PLATFORM_INLINE WORD64 ixheaacd_mac32x32in64_7(const WORD32 *a, const WORD16 *b) { + WORD64 sum; sum = (WORD64)a[0] * (WORD64)b[0]; sum += (WORD64)a[1] * (WORD64)b[1]; sum += (WORD64)a[2] * (WORD64)b[2]; diff --git a/decoder/ixheaacd_bitbuffer.c b/decoder/ixheaacd_bitbuffer.c index 0882689..4e6468f 100644 --- a/decoder/ixheaacd_bitbuffer.c +++ b/decoder/ixheaacd_bitbuffer.c @@ -17,17 +17,18 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ + #include <string.h> -#include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> #include <assert.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_bitbuffer.h" @@ -50,7 +51,7 @@ WORD32 ixheaacd_skip_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; WORD bit_pos = it_bit_buff->bit_pos; - if (it_bit_buff->cnt_bits < no_of_bits) + if (it_bit_buff->cnt_bits < no_of_bits || it_bit_buff->cnt_bits < 0) longjmp(*(it_bit_buff->xaac_jmp_buf), IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); it_bit_buff->cnt_bits -= no_of_bits; @@ -73,7 +74,12 @@ WORD32 ixheaacd_show_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { UWORD8 *ptr_read_next = it_bit_buff->ptr_read_next; WORD bit_pos = it_bit_buff->bit_pos; - if (it_bit_buff->cnt_bits < no_of_bits) { + if (no_of_bits == 0) { + return 0; + } + + if (it_bit_buff->cnt_bits < no_of_bits || it_bit_buff->cnt_bits < 0 || + no_of_bits > 25) { longjmp(*(it_bit_buff->xaac_jmp_buf), IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); } @@ -81,7 +87,7 @@ WORD32 ixheaacd_show_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { ret_val = (UWORD32)*ptr_read_next; bit_pos -= no_of_bits; - while (bit_pos < 0) { + while (bit_pos < -1) { bit_pos += 8; ptr_read_next++; @@ -90,6 +96,12 @@ WORD32 ixheaacd_show_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { ret_val |= (UWORD32)*ptr_read_next; } + if (bit_pos == -1) { + bit_pos += 8; + ret_val <<= 8; + ptr_read_next++; + } + ret_val = ret_val << ((31 - no_of_bits) - bit_pos) >> (32 - no_of_bits); return ret_val; @@ -104,7 +116,8 @@ WORD32 ixheaacd_read_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { return 0; } - if (it_bit_buff->cnt_bits < no_of_bits) { + if (it_bit_buff->cnt_bits < no_of_bits || it_bit_buff->cnt_bits < 0 || + no_of_bits > 25) { longjmp(*(it_bit_buff->xaac_jmp_buf), IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); } @@ -113,25 +126,19 @@ WORD32 ixheaacd_read_bits_buf(ia_bit_buf_struct *it_bit_buff, WORD no_of_bits) { ret_val = (UWORD32)*ptr_read_next; bit_pos -= no_of_bits; - if (0 == it_bit_buff->cnt_bits) { - while (bit_pos < -1) { - bit_pos += 8; - ptr_read_next++; - ret_val <<= 8; - ret_val |= (UWORD32)*ptr_read_next; - } + while (bit_pos < -1) { bit_pos += 8; - ret_val <<= 8; ptr_read_next++; - } else { - while (bit_pos < 0) { - bit_pos += 8; - ptr_read_next++; - ret_val <<= 8; + ret_val <<= 8; - ret_val |= (UWORD32)*ptr_read_next; - } + ret_val |= (UWORD32)*ptr_read_next; + } + + if (bit_pos == -1) { + bit_pos += 8; + ret_val <<= 8; + ptr_read_next++; } ret_val = ret_val << ((31 - no_of_bits) - bit_pos) >> (32 - no_of_bits); @@ -232,7 +239,7 @@ WORD32 ixheaacd_aac_read_bit_rev(ia_bit_buf_struct *it_bit_buff) { UWORD32 temp; WORD no_of_bits = 1; - if (it_bit_buff->cnt_bits < no_of_bits) { + if (it_bit_buff->cnt_bits < no_of_bits || it_bit_buff->cnt_bits < 0) { longjmp(*(it_bit_buff->xaac_jmp_buf), IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); } diff --git a/decoder/ixheaacd_block.c b/decoder/ixheaacd_block.c index d67e817..2784edd 100644 --- a/decoder/ixheaacd_block.c +++ b/decoder/ixheaacd_block.c @@ -18,17 +18,17 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_pulsedata.h" @@ -44,7 +44,7 @@ #include "ixheaacd_block.h" #include "ixheaacd_channel.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_tns.h" #include "ixheaacd_sbrdecoder.h" @@ -59,7 +59,9 @@ static PLATFORM_INLINE WORD32 ixheaacd_shr32_drc(WORD32 a, WORD32 b) { WORD32 out_val; b = ((UWORD32)(b << 24) >> 24); - if (b >= 31) { + if (b == 0) { + out_val = a; + } else if (b >= 31) { if (a < 0) out_val = -1; else diff --git a/decoder/ixheaacd_channel.c b/decoder/ixheaacd_channel.c index 6ebe402..73c5185 100644 --- a/decoder/ixheaacd_channel.c +++ b/decoder/ixheaacd_channel.c @@ -19,18 +19,18 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_error_codes.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -48,7 +48,7 @@ #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_stereo.h" @@ -67,7 +67,7 @@ #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_audioobjtypes.h" #include "ixheaacd_sbrdecoder.h" #include "ixheaacd_memory_standards.h" diff --git a/decoder/ixheaacd_common_initfuncs.c b/decoder/ixheaacd_common_initfuncs.c index bc5f5ff..88fadcc 100644 --- a/decoder/ixheaacd_common_initfuncs.c +++ b/decoder/ixheaacd_common_initfuncs.c @@ -19,16 +19,15 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -50,7 +49,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -75,7 +74,7 @@ #include "ixheaacd_multichannel.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_adts_crc_check.h" #include "ixheaacd_function_selector.h" @@ -158,30 +157,24 @@ ia_bit_buf_struct *ixheaacd_create_init_bit_buf(ia_bit_buf_struct *it_bit_buff, VOID ixheaacd_read_bidirection(ia_bit_buf_struct *it_bit_buff, WORD32 ixheaacd_drc_offset) { if (ixheaacd_drc_offset != 0) { - WORD32 bit_offset; - + WORD32 byte_offset; + if ((it_bit_buff->cnt_bits < 0) || + (it_bit_buff->cnt_bits - ixheaacd_drc_offset < 0) || + (it_bit_buff->cnt_bits - ixheaacd_drc_offset > it_bit_buff->size)) { + longjmp(*(it_bit_buff->xaac_jmp_buf), + IA_ENHAACPLUS_DEC_EXE_NONFATAL_INSUFFICIENT_INPUT_BYTES); + } it_bit_buff->cnt_bits = it_bit_buff->cnt_bits - ixheaacd_drc_offset; it_bit_buff->bit_pos = it_bit_buff->bit_pos - ixheaacd_drc_offset; - bit_offset = it_bit_buff->bit_pos >> 3; - it_bit_buff->bit_pos = it_bit_buff->bit_pos - (bit_offset << 3); + byte_offset = it_bit_buff->bit_pos >> 3; + it_bit_buff->bit_pos = it_bit_buff->bit_pos - (byte_offset << 3); - if (bit_offset) { + if (byte_offset) { UWORD8 *ptr_read_next; - WORD32 temp; ptr_read_next = it_bit_buff->ptr_read_next; - ptr_read_next = ptr_read_next - (bit_offset); - - temp = it_bit_buff->ptr_bit_buf_end - it_bit_buff->ptr_bit_buf_base + 1; - - if (ptr_read_next > it_bit_buff->ptr_bit_buf_end) { - ptr_read_next -= temp; - } - - if (ptr_read_next < it_bit_buff->ptr_bit_buf_base) { - ptr_read_next += temp; - } + ptr_read_next = ptr_read_next - (byte_offset); it_bit_buff->ptr_read_next = ptr_read_next; } diff --git a/decoder/ixheaacd_common_lpfuncs.c b/decoder/ixheaacd_common_lpfuncs.c index a9df44e..c9ab2dd 100644 --- a/decoder/ixheaacd_common_lpfuncs.c +++ b/decoder/ixheaacd_common_lpfuncs.c @@ -17,18 +17,16 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include "string.h" +#include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> - -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -50,7 +48,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -77,7 +75,7 @@ #include "ixheaacd_multichannel.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" static PLATFORM_INLINE UWORD32 @@ -217,7 +215,6 @@ VOID ixheaacd_read_data_stream_element(ia_bit_buf_struct *it_bit_buff, } it_bit_buff->ptr_read_next += cnt; it_bit_buff->cnt_bits -= ((cnt) << 3); - } VOID ixheaacd_read_fill_element(ia_bit_buf_struct *it_bit_buff, @@ -250,7 +247,6 @@ VOID ixheaacd_read_fill_element(ia_bit_buf_struct *it_bit_buff, } it_bit_buff->ptr_read_next += count - 1; it_bit_buff->cnt_bits -= ((count - 1) << 3); - } } } diff --git a/decoder/ixheaacd_common_rom.c b/decoder/ixheaacd_common_rom.c index e442f8f..819d6f2 100644 --- a/decoder/ixheaacd_common_rom.c +++ b/decoder/ixheaacd_common_rom.c @@ -18,16 +18,16 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -43,7 +43,7 @@ #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" diff --git a/decoder/ixheaacd_config.h b/decoder/ixheaacd_config.h index c6a540e..c78ce8f 100644 --- a/decoder/ixheaacd_config.h +++ b/decoder/ixheaacd_config.h @@ -161,6 +161,7 @@ typedef struct { #define DRC_BAND_COUNT_MAX BAND_COUNT_MAX #define SPEAKER_POS_COUNT_MAX (128) #define DOWNMIX_COEFF_COUNT_MAX (32 * 32) +#define MAX_AUDIO_PREROLLS 3 typedef struct { UINT32 tw_mdct; @@ -185,10 +186,13 @@ typedef struct { WORD32 usac_ext_ele_payload_present[USAC_MAX_ELEMENTS]; WORD32 usac_cfg_ext_info_len[USAC_MAX_CONFIG_EXTENSIONS]; WORD32 usac_ext_ele_payload_len[USAC_MAX_ELEMENTS]; - WORD32 usac_ext_gain_payload_len; + WORD32 usac_ext_gain_payload_len[MAX_AUDIO_PREROLLS + 2]; UWORD8 usac_cfg_ext_info_buf[USAC_MAX_CONFIG_EXTENSIONS][768]; UWORD8 usac_ext_ele_payload_buf[USAC_MAX_ELEMENTS][768]; - UWORD8 usac_ext_gain_payload_buf[768]; + UWORD8 usac_ext_gain_payload_buf[MAX_AUDIO_PREROLLS * 768]; + UWORD32 preroll_bytes[MAX_AUDIO_PREROLLS + + 2]; // Contain the number of bytes in each preroll + WORD32 preroll_counter; // count the number of prerolls in a frame. WORD32 preroll_flag; diff --git a/decoder/ixheaacd_constants.h b/decoder/ixheaacd_constants.h index 9c8d6d8..3ac0065 100644 --- a/decoder/ixheaacd_constants.h +++ b/decoder/ixheaacd_constants.h @@ -63,9 +63,14 @@ #define MAX_16 (WORD16)0x7fff #define MIN_16 (WORD16)0x8000 +#define MAX_24 (WORD32)0x007fffff +#define MIN_24 (WORD32)0xff800000 + #define NULLPTR ((VOID *)0) #define IT_NULL ((VOID *)0) + +#define ADJ_SCALE 11 /*****************************************************************************/ /* function macros */ /*****************************************************************************/ diff --git a/decoder/ixheaacd_create.c b/decoder/ixheaacd_create.c index 962b98c..6990399 100644 --- a/decoder/ixheaacd_create.c +++ b/decoder/ixheaacd_create.c @@ -22,7 +22,7 @@ #include <string.h> #include <assert.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_cnst.h" @@ -60,13 +60,12 @@ #include "ixheaacd_arith_dec.h" -#include <ixheaacd_type_def.h> #include "ixheaacd_memory_standards.h" #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_common_rom.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -99,19 +98,19 @@ #include "ixheaacd_func_def.h" #include "ixheaacd_interface.h" -extern ia_huff_code_word_struct ixheaacd_huff_book_scl[]; +extern const ia_huff_code_word_struct ixheaacd_huff_book_scl[]; -extern WORD32 ixheaacd_book_scl_index[]; -extern WORD16 ixheaacd_book_scl_code_book[]; +extern const WORD32 ixheaacd_book_scl_index[]; +extern const WORD16 ixheaacd_book_scl_code_book[]; -extern ia_usac_samp_rate_info ixheaacd_samp_rate_info[]; +extern const ia_usac_samp_rate_info ixheaacd_samp_rate_info[]; extern const WORD32 ixheaacd_sampling_boundaries[(1 << LEN_SAMP_IDX)]; const WORD32 ixheaacd_sampl_freq_idx_table[17] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, -1, -1, -1, -1}; -static VOID ixheaacd_info_init(ia_usac_samp_rate_info *ptr_samp_info, +static VOID ixheaacd_info_init(const ia_usac_samp_rate_info *ptr_samp_info, WORD32 block_size_samples, ia_sfb_info_struct *pstr_sfb_info_long, ia_sfb_info_struct *pstr_sfb_info_short, @@ -279,8 +278,11 @@ WORD32 ixheaacd_decode_init( for (i = 0; i < MAX_NUM_CHANNELS; i++) { usac_data->str_tddec[i] = &usac_data->arr_str_tddec[i]; - usac_data->str_tddec[i]->fscale = - ((fscale)*usac_data->ccfl) / LEN_SUPERFRAME; + if (usac_data->ccfl == 768) + usac_data->str_tddec[i]->fscale = pstr_stream_config->sampling_frequency; + else + usac_data->str_tddec[i]->fscale = + ((fscale)*usac_data->ccfl) / LEN_SUPERFRAME; usac_data->len_subfrm = usac_data->ccfl / 4; usac_data->num_subfrm = (MAX_NUM_SUBFR * usac_data->ccfl) / LEN_SUPERFRAME; diff --git a/decoder/ixheaacd_decode_main.c b/decoder/ixheaacd_decode_main.c index 8bb71da..7ee1bcd 100644 --- a/decoder/ixheaacd_decode_main.c +++ b/decoder/ixheaacd_decode_main.c @@ -19,21 +19,20 @@ */ #include <stdlib.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" +#include "ixheaacd_constants.h" #include "ixheaacd_error_standards.h" #include "ixheaacd_memory_standards.h" #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_env_extr_part.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_common_rom.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" - #include "ixheaacd_lt_predict.h" - #include "ixheaacd_channelinfo.h" #include "ixheaacd_sbr_common.h" #include "ixheaacd_drc_data_struct.h" @@ -45,44 +44,33 @@ #include "ixheaacd_latmdemux.h" #include "ixheaacd_aacdec.h" #include "ixheaacd_sbr_common.h" - #include "ixheaacd_mps_polyphase.h" #include "ixheaacd_config.h" #include "ixheaacd_mps_dec.h" - #include "ixheaacd_struct_def.h" - -#include <ixheaacd_type_def.h> #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" - #include "ixheaacd_tns_usac.h" #include "ixheaacd_cnst.h" - #include "ixheaacd_acelp_info.h" - #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_info.h" #include "ixheaacd_sbrdecoder.h" #include "ixheaacd_mps_polyphase.h" #include "ixheaacd_sbr_const.h" #include "ixheaacd_main.h" - #include "ixheaacd_arith_dec.h" - #include "ixheaacd_config.h" #include "ixheaacd_struct.h" - #include "ixheaacd_create.h" - #include "ixheaacd_dec_main.h" - +#include "ixheaacd_error_standards.h" VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, WORD32 pcmsize, FLOAT32 (*out_samples)[4096], WORD32 *out_bytes, WORD32 num_channel_out) { WORD32 num; WORD32 i; - WORD64 write_local; + FLOAT32 sample; WORD16 *out_buf = (WORD16 *)outbuffer; @@ -90,31 +78,30 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, if (pcmsize == 16) { for (i = 0; i < num; i++) { - write_local = - ((WORD64)(out_samples[i % num_channel_out][i / num_channel_out])); + sample = (out_samples[i % num_channel_out][i / num_channel_out]); - if (write_local > 32767) { - write_local = 32767; - } - if (write_local < -32768) { - write_local = -32768; + if (sample > MAX_16) { + sample = MAX_16; + } else if (sample < MIN_16) { + sample = MIN_16; } - out_buf[i] = (WORD16)write_local; + out_buf[i] = (WORD16)sample; } *out_bytes = num * sizeof(WORD16); } else { WORD8 *out_24bit = (WORD8 *)out_buf; for (i = 0; i < num; i++) { - write_local = ((WORD64)( - out_samples[i % num_channel_out][i / num_channel_out] * 256)); + WORD32 write_local; + sample = (out_samples[i % num_channel_out][i / num_channel_out] * 256); - if (write_local > 8388607) { - write_local = 8388607; - } - if (write_local < -8388608) { - write_local = -8388608; + if (sample > MAX_24) { + sample = MAX_24; + } else if (sample < MIN_24) { + sample = MIN_24; } + write_local = (WORD32)sample; + *out_24bit++ = (WORD32)write_local & 0xff; *out_24bit++ = ((WORD32)write_local >> 8) & 0xff; *out_24bit++ = ((WORD32)write_local >> 16) & 0xff; @@ -141,8 +128,7 @@ static WORD32 ixheaacd_audio_preroll_parsing(ia_dec_data_struct *pstr_dec_data, WORD32 num_pre_roll_frames = 0; WORD32 frame_idx = 0; - WORD32 frame_len[18] = { - 0}; // max of escapedValue(2, 4, 0) i.e. 2^2 -1 + 2^4 -1; + WORD32 frame_len[MAX_AUDIO_PREROLLS] = {0}; WORD32 temp = 0; WORD32 config_len = 0; @@ -196,6 +182,8 @@ static WORD32 ixheaacd_audio_preroll_parsing(ia_dec_data_struct *pstr_dec_data, num_pre_roll_frames += val_add; } + if (num_pre_roll_frames > MAX_AUDIO_PREROLLS) return IA_FATAL_ERROR; + for (frame_idx = 0; frame_idx < num_pre_roll_frames; frame_idx++) { WORD32 au_len = 0; // escapedValued(16,16,0) au_len = ixheaacd_read_bits_buf(temp_buff, 16); @@ -259,6 +247,7 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, } { + WORD32 tot_out_bytes = 0; pstr_dec_data = (ia_dec_data_struct *)aac_dec_handle->pstr_dec_data; if (frames_done == 0) { @@ -297,6 +286,8 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, config_len = ixheaacd_audio_preroll_parsing(pstr_dec_data, &config[0], &preroll_units, &preroll_frame_offset[0]); + + if (config_len == IA_FATAL_ERROR) return IA_FATAL_ERROR; } if (config_len != 0) { @@ -386,25 +377,61 @@ WORD32 ixheaacd_dec_main(VOID *temp_handle, WORD8 *inbuffer, WORD8 *outbuffer, num_samples_out = pstr_dec_data->str_usac_data.output_samples; - ixheaacd_samples_sat(outbuffer, num_samples_out, pcmsize, + ixheaacd_samples_sat((WORD8 *)outbuffer + tot_out_bytes, num_samples_out, + pcmsize, pstr_dec_data->str_usac_data.time_sample_vector, out_bytes, *num_channel_out); - pstr_audio_specific_config->str_usac_config.str_usac_dec_config - .usac_ext_gain_payload_len = - pstr_dec_data->str_frame_data.str_audio_specific_config - .str_usac_config.str_usac_dec_config.usac_ext_gain_payload_len; - memcpy(pstr_audio_specific_config->str_usac_config.str_usac_dec_config - .usac_ext_gain_payload_buf, - pstr_dec_data->str_frame_data.str_audio_specific_config - .str_usac_config.str_usac_dec_config.usac_ext_gain_payload_buf, - pstr_dec_data->str_frame_data.str_audio_specific_config - .str_usac_config.str_usac_dec_config - .usac_ext_gain_payload_len * - sizeof(WORD8)); + { + WORD32 preroll_counter = + pstr_dec_data->str_frame_data.str_audio_specific_config + .str_usac_config.str_usac_dec_config.preroll_counter; + + UWORD8 i; // for looping index used for payload calculation + WORD32 payload_buffer_offset = 0; + WORD32 copy_bytes = + pstr_dec_data->str_frame_data.str_audio_specific_config + .str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len[preroll_counter] * + sizeof(WORD8); + + pstr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len[preroll_counter] = + pstr_dec_data->str_frame_data.str_audio_specific_config + .str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len[preroll_counter]; + + for (i = 0; i < preroll_counter; i++) + payload_buffer_offset += + pstr_dec_data->str_frame_data.str_audio_specific_config + .str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_len[i] * + sizeof(WORD8); + + memcpy(pstr_audio_specific_config->str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_buf + + payload_buffer_offset, + pstr_dec_data->str_frame_data.str_audio_specific_config + .str_usac_config.str_usac_dec_config + .usac_ext_gain_payload_buf + + payload_buffer_offset, + copy_bytes); + + pstr_audio_specific_config->str_usac_config.str_usac_dec_config + .preroll_bytes[preroll_counter] = *out_bytes; + + preroll_counter++; + + if (preroll_counter > (MAX_AUDIO_PREROLLS + 1)) return IA_FATAL_ERROR; + + pstr_dec_data->str_frame_data.str_audio_specific_config.str_usac_config + .str_usac_dec_config.preroll_counter = preroll_counter; + } access_units++; preroll_units--; + tot_out_bytes += (*out_bytes); } while (preroll_units >= 0); + *out_bytes = tot_out_bytes; } return err; diff --git a/decoder/ixheaacd_definitions.h b/decoder/ixheaacd_definitions.h index 8762096..78b9af0 100644 --- a/decoder/ixheaacd_definitions.h +++ b/decoder/ixheaacd_definitions.h @@ -39,13 +39,18 @@ #define IA_MPS_DEC_INPUT_IDX (2) #define IA_MPS_DEC_MPS_INPUT_IDX (3) #define IA_MPS_DEC_OUTPUT_IDX (4) +#define IA_MAX_PREROLL_FRAMES (4) +#define IA_MAX_OUTPUT_PCM_SIZE (3) +#define IA_MAX_USAC_CH (2) +#define IA_MAX_OUT_SAMPLES_PER_FRAME (4096) #define IA_ENHAACPLUS_DEC_INP_BUF_SIZE (6144 / 8) #define IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME (1024) -#define IA_ENHAACPLUS_DEC_OUT_BUF_SIZE \ - (2 * IA_ENHAACPLUS_DEC_SAMPLES_PER_FRAME * sizeof(WORD16)) +#define IA_ENHAACPLUS_DEC_OUT_BUF_SIZE \ + (IA_MAX_USAC_CH * IA_MAX_PREROLL_FRAMES * IA_MAX_OUT_SAMPLES_PER_FRAME * \ + IA_MAX_OUTPUT_PCM_SIZE) #define IA_MPS_DEC_INP_BUF_SIZE (0) #define IA_MPS_DEC_OUT_BUF_SIZE (0) diff --git a/decoder/ixheaacd_drc_freq_dec.c b/decoder/ixheaacd_drc_freq_dec.c index 48a83e3..cd6b81d 100644 --- a/decoder/ixheaacd_drc_freq_dec.c +++ b/decoder/ixheaacd_drc_freq_dec.c @@ -18,9 +18,9 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <string.h> -#include "stdio.h" -#include "math.h" -#include <ixheaacd_type_def.h> +#include <stdio.h> +#include <math.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_sbr_common.h" #include "ixheaacd_cnst.h" @@ -31,7 +31,7 @@ #include "ixheaacd_basic_ops.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_error_standards.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_defines.h" @@ -56,9 +56,6 @@ #include "ixheaacd_sbr_payload.h" #include "ixheaacd_common_rom.h" - -#include <ixheaacd_type_def.h> - #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_env_extr_part.h" @@ -115,7 +112,7 @@ static PLATFORM_INLINE WORD32 ixheaacd_mult32x16in32_shift25(WORD32 a, return (result); } -static WORD32 ixheaacd_drc_pow_tbl_2_q29[] = { +static const WORD32 ixheaacd_drc_pow_tbl_2_q29[] = { 536870912, 537242967, 537615991, 537988562, 538361391, 538734479, 539108539, 539482144, 539856009, 540230847, 540605230, 540979873, 541354776, 541730654, 542106077, 542481760, 542858421, 543234626, @@ -284,7 +281,7 @@ static WORD32 ixheaacd_drc_pow_tbl_2_q29[] = { 1066324778, 1067063748, 1067804642, 1068544637, 1069285146, 1070027582, 1070769118, 1071511168, 1072253732, 1072998229}; -static WORD32 ixheaacd_drc_pow_tbl_1_2_q29[] = { +static const WORD32 ixheaacd_drc_pow_tbl_1_2_q29[] = { 536870912, 536499115, 536126866, 535755584, 535384559, 535013791, 534642573, 534272319, 533902321, 533531874, 533162389, 532793160, 532424187, 532054765, 531686303, 531318096, 530949443, 530581746, 530214304, 529847117, 529479484, @@ -878,7 +875,7 @@ VOID ixheaacd_drc_apply(ia_drc_dec_struct *pstr_drc_dec, WORD32 drc_band, spec_pos, start_pos, end_pos; WORD32 low_hi, drc_norm, drc_freq_fac; WORD32 drc_fac, div_val, mod_val, ret_val, offset_value; - WORD32 *table; + const WORD32 *table; ixheaac_drc_data_struct *pstr_drc_data; WORD32 num_qmf_sub_sample = (frame_size >> 5); WORD32 num_qmf_sub_sample_by_2 = (frame_size >> 6); diff --git a/decoder/ixheaacd_dsp_fft32x32s.c b/decoder/ixheaacd_dsp_fft32x32s.c index 0e6a89f..d13b053 100644 --- a/decoder/ixheaacd_dsp_fft32x32s.c +++ b/decoder/ixheaacd_dsp_fft32x32s.c @@ -18,18 +18,18 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_dsp_fft32x32s.h" #include "ixheaacd_intrinsics.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" VOID ixheaacd_inv_dit_fft_8pt_dec(WORD32 *y, WORD32 *real, WORD32 *imag) { WORD32 a0, a1, a2, a3, a00, a10, a20, a30; diff --git a/decoder/ixheaacd_env_calc.c b/decoder/ixheaacd_env_calc.c index 8d31290..dd873a8 100644 --- a/decoder/ixheaacd_env_calc.c +++ b/decoder/ixheaacd_env_calc.c @@ -18,12 +18,12 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_intrinsics.h" @@ -33,7 +33,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -47,7 +47,7 @@ #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" @@ -60,7 +60,7 @@ #include "ixheaacd_env_extr.h" #include "ixheaacd_env_calc.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_qmf_dec.h" @@ -664,7 +664,7 @@ VOID ixheaacd_calc_subband_gains(ia_freq_band_data_struct *pstr_freq_band_data, #define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) -VOID ixheaacd_calc_sbrenvelope( +IA_ERRORCODE ixheaacd_calc_sbrenvelope( ia_sbr_scale_fact_struct *ptr_sbr_scale_fac, ia_sbr_calc_env_struct *ptr_sbr_calc_env, ia_sbr_header_data_struct *ptr_header_data, @@ -681,7 +681,7 @@ VOID ixheaacd_calc_sbrenvelope( WORD32 freq_res; WORD32 num_env = ptr_frame_data->str_frame_info_details.num_env; WORD16 *ptr_border_vec = ptr_frame_data->str_frame_info_details.border_vec; - + IA_ERRORCODE err_code = IA_NO_ERROR; WORD16 *ptr_noise_floor; ia_freq_band_data_struct *pstr_freq_band_data = ptr_header_data->pstr_freq_band_data; @@ -809,8 +809,12 @@ VOID ixheaacd_calc_sbrenvelope( start_pos = SBR_TIME_STEP * ptr_border_vec[i]; end_pos = SBR_TIME_STEP * ptr_border_vec[i + 1]; } + if ((start_pos >= MAX_ENV_COLS) || (end_pos > MAX_ENV_COLS)) + return IA_FATAL_ERROR; freq_res = ptr_frame_data->str_frame_info_details.freq_res[i]; + if (noise_floor_idx >= MAX_NOISE_ENVELOPES) return IA_FATAL_ERROR; + if (ptr_border_vec[i] == ptr_frame_data->str_frame_info_details .noise_border_vec[noise_floor_idx + 1]) { @@ -944,6 +948,7 @@ VOID ixheaacd_calc_sbrenvelope( } else { ptr_sbr_calc_env->tansient_env_prev = -1; } + return err_code; } VOID ixheaacd_equalize_filt_buff_exp(WORD16 *ptr_filt_buf, WORD16 *nrg_gain, diff --git a/decoder/ixheaacd_env_calc.h b/decoder/ixheaacd_env_calc.h index 7941ab3..dd2e195 100644 --- a/decoder/ixheaacd_env_calc.h +++ b/decoder/ixheaacd_env_calc.h @@ -31,7 +31,7 @@ typedef struct { WORD16 harm_index; } ia_sbr_calc_env_struct; -VOID ixheaacd_calc_sbrenvelope( +IA_ERRORCODE ixheaacd_calc_sbrenvelope( ia_sbr_scale_fact_struct *sbr_scale_factor, ia_sbr_calc_env_struct *ptr_sbr_calc_env, ia_sbr_header_data_struct *ptr_header_data, diff --git a/decoder/ixheaacd_env_dec.c b/decoder/ixheaacd_env_dec.c index e363def..ac8b3c9 100644 --- a/decoder/ixheaacd_env_dec.c +++ b/decoder/ixheaacd_env_dec.c @@ -18,36 +18,31 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <string.h> +#include <math.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_error_standards.h" - #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops16.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" - -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.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_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" - #include "ixheaacd_env_extr.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_env_dec.h" #include "ixheaacd_sbr_const.h" - #include "ixheaacd_basic_funcs.h" -#include "math.h" - #define add16_m(a, b) ((a) + (b)) #define sub16_m(a, b) ((a) - (b)) @@ -58,7 +53,7 @@ static VOID ixheaacd_dequant_esbr_env_data(FLOAT32 *ptr_env_sf, WORD32 num_noise_fac, WORD32 amp_res, FLOAT32 *ptr_noise_floor) { WORD32 i; - FLOAT32 array[2] = {0.5f, 1.0f}; + static const FLOAT32 array[2] = {0.5f, 1.0f}; FLOAT32 a_flt = array[amp_res]; for (i = 0; i < num_env_sf; i++) { @@ -328,7 +323,7 @@ VOID ixheaacd_dequant_env_data(ia_sbr_frame_info_data_struct *ptr_sbr_data, WORD32 exponent; WORD32 exp_add = (7 + NRG_EXP_OFFSET); WORD16 *ptr_env_sf = ptr_sbr_data->int_env_sf_arr; - WORD32 mant_arr[2] = {0x4000, 0x5a80}; + static const WORD32 mant_arr[2] = {0x4000, 0x5a80}; amp_res_1 = (1 - amp_res); @@ -433,7 +428,8 @@ IA_ERRORCODE ixheaacd_calc_noise_floor( memcpy(ptr2, ptr1, sizeof(WORD16) * (num_nf_bands)); - if (ptr_sbr_data->coupling_mode != COUPLING_BAL) { + if ((ptr_sbr_data->coupling_mode != COUPLING_BAL) || + (ptr_header_data->usac_flag)) { WORD32 noise_floor_exp, tot_nf_bands; tot_nf_bands = (num_nf_bands * num_noise_env); @@ -551,8 +547,8 @@ VOID ixheaacd_sbr_env_dequant_coup( WORD32 i; FLOAT32 temp_l, temp_r; - FLOAT32 pan_offset[2] = {24.0f, 12.0f}; - FLOAT32 a_arr[2] = {0.5f, 1.0f}; + static const FLOAT32 pan_offset[2] = {24.0f, 12.0f}; + static const FLOAT32 a_arr[2] = {0.5f, 1.0f}; FLOAT32 a = a_arr[amp_res]; @@ -648,6 +644,9 @@ WORD32 ixheaacd_dec_sbrdata(ia_sbr_header_data_struct *ptr_header_data_ch_0, } if (ptr_sbr_data_ch_0->coupling_mode) { + ptr_sbr_data_ch_0->num_noise_sfac = + ptr_header_data_ch_1->pstr_freq_band_data->num_nf_bands * + ptr_sbr_data_ch_1->str_frame_info_details.num_noise_env; ixheaacd_sbr_env_dequant_coup_fix(ptr_header_data_ch_0, ptr_sbr_data_ch_0, ptr_sbr_data_ch_1, ptr_common_tables); diff --git a/decoder/ixheaacd_env_extr.c b/decoder/ixheaacd_env_extr.c index 728d8a1..dca8171 100644 --- a/decoder/ixheaacd_env_extr.c +++ b/decoder/ixheaacd_env_extr.c @@ -18,16 +18,17 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <string.h> +#include <math.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" @@ -40,13 +41,11 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" -#include <math.h> - #include "ixheaacd_sbr_const.h" #include "ixheaacd_intrinsics.h" @@ -1551,7 +1550,7 @@ WORD16 ixheaacd_sbr_time_freq_grid_info( bs_var_bord = 0, temp = 0; WORD32 freq_res_0 = 0, frame_class; WORD32 abs_bord_lead, abs_bord_trail, num_rel_trail, num_rel_lead; - WORD32 pointer_bits_array[7] = {1, 2, 2, 3, 3, 3, 3}; + static const WORD32 pointer_bits_array[7] = {1, 2, 2, 3, 3, 3, 3}; ia_frame_info_struct *p_fixfix_tab; ia_frame_info_struct *p_frame_info = &ptr_frame_data->str_frame_info_details; @@ -1733,4 +1732,4 @@ WORD16 ixheaacd_sbr_time_freq_grid_info( p_frame_info->border_vec[bs_num_env]; } return 1; -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_env_extr.h b/decoder/ixheaacd_env_extr.h index 109dfe2..d699b5e 100644 --- a/decoder/ixheaacd_env_extr.h +++ b/decoder/ixheaacd_env_extr.h @@ -31,6 +31,7 @@ #define ROUNDING (1 << (EXP_BITS - 1)) #define NRG_EXP_OFFSET 16 #define NOISE_EXP_OFFSET 38 +#define MAX_QMF_SUB_BANDS 64 typedef const UWORD16 *ia_huffman_data_type; @@ -100,13 +101,13 @@ typedef struct { WORD32 gate_mode[4]; WORD8 harm_flag_varlen_prev[64]; WORD8 harm_flag_varlen[64]; - FLOAT32 qmapped_pvc[64][48]; - FLOAT32 env_tmp[64][48]; - FLOAT32 noise_level_pvc[64][48]; - FLOAT32 nrg_est_pvc[64][48]; - FLOAT32 nrg_ref_pvc[64][48]; - FLOAT32 nrg_gain_pvc[64][48]; - FLOAT32 nrg_tone_pvc[64][48]; + FLOAT32 qmapped_pvc[MAX_QMF_SUB_BANDS][MAX_FREQ_COEFFS_SBR]; + FLOAT32 env_tmp[MAX_QMF_SUB_BANDS][MAX_FREQ_COEFFS_SBR]; + FLOAT32 noise_level_pvc[MAX_QMF_SUB_BANDS][MAX_FREQ_COEFFS_SBR]; + FLOAT32 nrg_est_pvc[MAX_QMF_SUB_BANDS][MAX_FREQ_COEFFS_SBR]; + FLOAT32 nrg_ref_pvc[MAX_QMF_SUB_BANDS][MAX_FREQ_COEFFS_SBR]; + FLOAT32 nrg_gain_pvc[MAX_QMF_SUB_BANDS][MAX_FREQ_COEFFS_SBR]; + FLOAT32 nrg_tone_pvc[MAX_QMF_SUB_BANDS][MAX_FREQ_COEFFS_SBR]; WORD32 stereo_config_idx; FLAG reset_flag; FLAG mps_sbr_flag; diff --git a/decoder/ixheaacd_error_handler.h b/decoder/ixheaacd_error_handler.h index 83cbdc1..f4b3ac1 100644 --- a/decoder/ixheaacd_error_handler.h +++ b/decoder/ixheaacd_error_handler.h @@ -40,6 +40,8 @@ #define IA_ERROR_CLASS_E 0xE #define IA_ERROR_CLASS_F 0xF +#define IA_MAX_ERROR_SUB_CODE 28 + typedef struct { pWORD8 pb_module_name; pWORD8 ppb_class_names[16]; diff --git a/decoder/ixheaacd_esbr_envcal.c b/decoder/ixheaacd_esbr_envcal.c index a3382c3..492287d 100644 --- a/decoder/ixheaacd_esbr_envcal.c +++ b/decoder/ixheaacd_esbr_envcal.c @@ -21,7 +21,7 @@ #include <math.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_error_standards.h" #include "ixheaacd_sbr_const.h" #include "ixheaacd_sbrdecsettings.h" @@ -30,11 +30,9 @@ #include "ixheaacd_drc_data_struct.h" #include "ixheaacd_drc_dec.h" #include "ixheaacd_sbrdecoder.h" - #include "ixheaacd_bitbuffer.h" - #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_sbr_scale.h" @@ -45,6 +43,8 @@ #include "ixheaacd_esbr_rom.h" +#define ABS(A) fabs(A) + VOID ixheaacd_shellsort(WORD32 *in, WORD32 n) { WORD32 i, j, v; WORD32 inc = 1; @@ -207,12 +207,14 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, } for (i = 0; i < bs_num_env; i++) { + if (kk > MAX_NOISE_ENVELOPES) return IA_FATAL_ERROR; if (p_frame_info->border_vec[i] == p_frame_info->noise_border_vec[kk]) kk++, next++; start_pos = p_frame_info->border_vec[i]; end_pos = p_frame_info->border_vec[i + 1]; - + if ((start_pos < 0) || (end_pos > MAX_FREQ_COEFFS_SBR)) + return IA_FATAL_ERROR; for (t = start_pos; t < end_pos; t++) { band_loop_end = num_sf_bands[p_frame_info->freq_res[i]]; @@ -224,6 +226,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, for (k = 0; k < ui - li; k++) { o = (k + li >= ui2) ? o + 1 : o; + if (o >= MAX_NOISE_COEFFS) return IA_FATAL_ERROR; ui2 = freq_band_table_noise[o + 1]; frame_data->qmapped_pvc[c][t] = @@ -238,12 +241,14 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, next = -1; for (i = 0; i < bs_num_env; i++) { + if (kk > MAX_NOISE_ENVELOPES) return IA_FATAL_ERROR; if (p_frame_info->border_vec[i] == p_frame_info->noise_border_vec[kk]) kk++, next++; start_pos = pvc_frame_info->border_vec[i]; end_pos = pvc_frame_info->border_vec[i + 1]; - + if ((start_pos < 0) || (end_pos > MAX_FREQ_COEFFS_SBR)) + return IA_FATAL_ERROR; for (t = start_pos; t < end_pos; t++) { for (c = 0; c < 64; c++) { env_tmp[c][t] = env_out[64 * t + c]; @@ -301,6 +306,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, for (k = 0; k < ui - li; k++) { o = (k + li >= ui2) ? o + 1 : o; + if (o >= MAX_NOISE_COEFFS) return IA_FATAL_ERROR; ui2 = freq_band_table_noise[o + 1]; nrg_est_pvc[c][t] = (!int_mode) ? nrg : nrg_est_pvc[c][t]; nrg_tone_pvc[c][t] = 0.0f; @@ -419,6 +425,7 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, for (k = 0; k < ui - li; k++) { o = (k + li >= ui2) ? o + 1 : o; + if (o >= MAX_NOISE_COEFFS) return IA_FATAL_ERROR; ui2 = freq_band_table_noise[o + 1]; nrg_est_pvc[c][t] = (!int_mode) ? nrg : nrg_est_pvc[c][t]; nrg_tone_pvc[c][t] = 0.0f; @@ -610,7 +617,9 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, c -= (ui - li); for (k = 0; k < ui - li; k++) { + FLOAT64 guard = 1e-17; o = (k + li >= ui2) ? o + 1 : o; + if (o >= MAX_NOISE_COEFFS) return IA_FATAL_ERROR; ui2 = frame_data->pstr_sbr_header->pstr_freq_band_data ->freq_band_tbl_noise[o + 1]; nrg_ref[c] = sfb_nrg[m]; @@ -624,16 +633,16 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, (harmonics[c] && (i >= trans_env || (*harm_flag_prev)[c + sub_band_start])) ? sqrt(nrg_ref[c] * tmp / - noise_floor[next * num_nf_bands + o]) + ABS(noise_floor[next * num_nf_bands + o] + guard)) : nrg_tone[c]); } else { if (noise_absc_flag) nrg_gain[c] = (FLOAT32)sqrt(nrg_ref[c] / (nrg_est[c] + 1)); else - nrg_gain[c] = - (FLOAT32)sqrt(nrg_ref[c] * tmp / - ((nrg_est[c] + 1) * - (noise_floor[next * num_nf_bands + o]))); + nrg_gain[c] = (FLOAT32)sqrt( + nrg_ref[c] * tmp / + ((nrg_est[c] + 1) * + ABS(noise_floor[next * num_nf_bands + o] + guard))); } noise_level[c] = (FLOAT32)sqrt(nrg_ref[c] * tmp); c++; @@ -778,6 +787,10 @@ WORD32 ixheaacd_sbr_env_calc(ia_sbr_frame_info_data_struct *frame_data, frame_data->var_len_id_prev = 1; } + if ((frame_data->str_frame_info_details.num_noise_env < 1) || + (frame_data->str_frame_info_details.num_noise_env > 2)) + return IA_FATAL_ERROR; + for (i = 0; i < num_nf_bands; i++) { prev_env_noise_level[i] = frame_data->flt_noise_floor diff --git a/decoder/ixheaacd_esbr_fft.c b/decoder/ixheaacd_esbr_fft.c index 24916ae..8a5b616 100644 --- a/decoder/ixheaacd_esbr_fft.c +++ b/decoder/ixheaacd_esbr_fft.c @@ -20,9 +20,9 @@ #include <stdio.h> #include <stdlib.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> +#include "ixheaacd_basic_ops32.h" #define PLATFORM_INLINE __inline @@ -35,7 +35,7 @@ (j) = _ >> (m); \ } while (0) -extern FLOAT32 ixheaacd_twiddle_table_fft_float[514]; +extern const FLOAT32 ixheaacd_twiddle_table_fft_float[514]; const FLOAT32 ixheaacd_twidle_tbl_48[64]; const FLOAT32 ixheaacd_twidle_tbl_24[32]; diff --git a/decoder/ixheaacd_esbr_polyphase.c b/decoder/ixheaacd_esbr_polyphase.c index d51a14c..8da3c57 100644 --- a/decoder/ixheaacd_esbr_polyphase.c +++ b/decoder/ixheaacd_esbr_polyphase.c @@ -17,7 +17,8 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include <string.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" #include "ixheaacd_sbr_common.h" @@ -28,7 +29,7 @@ #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbrdecoder.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_sbr_scale.h" @@ -44,8 +45,6 @@ #include "ixheaacd_qmf_poly.h" #include "ixheaacd_esbr_rom.h" -#include "string.h" - WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) { WORD32 idx; WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size; @@ -252,4 +251,4 @@ WORD32 ixheaacd_real_synth_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, } } return 0; -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_esbr_rom.c b/decoder/ixheaacd_esbr_rom.c index 095e180..9a65972 100644 --- a/decoder/ixheaacd_esbr_rom.c +++ b/decoder/ixheaacd_esbr_rom.c @@ -17,8 +17,9 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_sbr_const.h" +#include "ixheaacd_esbr_rom.h" const FLOAT32 ixheaacd_sub_samp_qmf_window_coeff[40 + 80 + 120 + 160 + 200 + 240 + 320 + 400] = { @@ -941,19 +942,18 @@ const FLOAT32 ixheaacd_hphase_tbl[2][8] = {{1.0f, 0.0f, -1.0f, 0.0f}, const FLOAT32 ixheaacd_g_lim_gains[4] = {0.70795f, 1.0f, 1.41254f, 1e10f}; -typedef const FLOAT32 FIR_FILTER[5]; -FIR_FILTER ixheaacd_fir_0 = {1.0f}; -FIR_FILTER ixheaacd_fir_1 = {0.33333333333333f, 0.66666666666666f}; -FIR_FILTER ixheaacd_fir_2 = {0.12500000000000f, 0.37500000000000f, - 0.50000000000000f}; -FIR_FILTER ixheaacd_fir_3 = {0.05857864376269f, 0.20000000000000f, - 0.34142135623731f, 0.40000000000000f}; -FIR_FILTER ixheaacd_fir_4 = {0.03183050093751f, 0.11516383427084f, - 0.21816949906249f, 0.30150283239582f, - 0.33333333333333f}; -FIR_FILTER *ixheaacd_fir_table[5] = {&ixheaacd_fir_0, &ixheaacd_fir_1, - &ixheaacd_fir_2, &ixheaacd_fir_3, - &ixheaacd_fir_4}; +const FIR_FILTER ixheaacd_fir_0 = {1.0f}; +const FIR_FILTER ixheaacd_fir_1 = {0.33333333333333f, 0.66666666666666f}; +const FIR_FILTER ixheaacd_fir_2 = {0.12500000000000f, 0.37500000000000f, + 0.50000000000000f}; +const FIR_FILTER ixheaacd_fir_3 = {0.05857864376269f, 0.20000000000000f, + 0.34142135623731f, 0.40000000000000f}; +const FIR_FILTER ixheaacd_fir_4 = {0.03183050093751f, 0.11516383427084f, + 0.21816949906249f, 0.30150283239582f, + 0.33333333333333f}; +const FIR_FILTER* const ixheaacd_fir_table[5] = { + &ixheaacd_fir_0, &ixheaacd_fir_1, &ixheaacd_fir_2, &ixheaacd_fir_3, + &ixheaacd_fir_4}; const FLOAT32 ixheaacd_q_gamma_table[4] = {0.0f, 1.0f, 2.0f, 4.0f}; const WORD32 ixheaacd_start_subband2kL_tbl[33] = { diff --git a/decoder/ixheaacd_esbr_rom.h b/decoder/ixheaacd_esbr_rom.h index 253f8c3..34eef98 100644 --- a/decoder/ixheaacd_esbr_rom.h +++ b/decoder/ixheaacd_esbr_rom.h @@ -27,13 +27,13 @@ extern const FLOAT32 ixheaacd_hphase_tbl[2][8]; extern const FLOAT32 ixheaacd_g_lim_gains[4]; -typedef const FLOAT32 FIR_FILTER[5]; -extern FIR_FILTER ixheaacd_fir_0; -extern FIR_FILTER ixheaacd_fir_1; -extern FIR_FILTER ixheaacd_fir_2; -extern FIR_FILTER ixheaacd_fir_3; -extern FIR_FILTER ixheaacd_fir_4; -extern FIR_FILTER *ixheaacd_fir_table[5]; +typedef FLOAT32 FIR_FILTER[5]; +extern const FIR_FILTER ixheaacd_fir_0; +extern const FIR_FILTER ixheaacd_fir_1; +extern const FIR_FILTER ixheaacd_fir_2; +extern const FIR_FILTER ixheaacd_fir_3; +extern const FIR_FILTER ixheaacd_fir_4; +extern const FIR_FILTER* const ixheaacd_fir_table[5]; extern const FLOAT32 ixheaacd_q_gamma_table[4]; extern const WORD32 ixheaacd_start_subband2kL_tbl[33]; extern const FLOAT32 ixheaacd_cos_table_trans_qmf[7][32 * 2]; @@ -47,15 +47,15 @@ extern const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_3[2 * (128 + 128)]; extern const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_4[2 * (128 + 128)]; extern const FLOAT32 ixheaacd_hbe_x_prod_cos_table_trans_4_1[2 * (128 + 128)]; -extern const FLOAT32 ixheaacd_synth_cos_table_kl_4[8 * 4]; -extern const FLOAT32 ixheaacd_synth_cos_table_kl_8[16 * 8]; -extern const FLOAT32 ixheaacd_synth_cos_table_kl_12[24 * 12]; -extern const FLOAT32 ixheaacd_synth_cos_table_kl_16[32 * 16]; +extern const FLOAT32 ixheaacd_synth_cos_table_kl_4[16]; +extern const FLOAT32 ixheaacd_synth_cos_table_kl_8[32]; +extern const FLOAT32 ixheaacd_synth_cos_table_kl_12[48]; +extern const FLOAT32 ixheaacd_synth_cos_table_kl_16[64]; extern const FLOAT32 ixheaacd_synth_cos_table_kl_20[40 * 20]; -extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_8[8 * 8 * 2]; -extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_16[16 * 16 * 2]; -extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_24[24 * 24 * 2]; -extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_32[32 * 32 * 2]; -extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_40[40 * 80 * 2]; +extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_8[32]; +extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_16[64]; +extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_24[96]; +extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_32[128]; +extern const FLOAT32 ixheaacd_analy_cos_sin_table_kl_40[40 * 40 * 2]; extern const FLOAT32 ixheaacd_sel_case[5][8]; #endif diff --git a/decoder/ixheaacd_ext_ch_ele.c b/decoder/ixheaacd_ext_ch_ele.c index 01506e7..0bb08e4 100644 --- a/decoder/ixheaacd_ext_ch_ele.c +++ b/decoder/ixheaacd_ext_ch_ele.c @@ -21,7 +21,7 @@ #include <string.h> #include <stdlib.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_cnst.h" @@ -50,9 +50,8 @@ #include "ixheaacd_bit_extract.h" #include "ixheaacd_constants.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_func_def.h" @@ -70,7 +69,7 @@ const WORD16 ixheaacd_mdst_fcoeff_long_sin_kbd[] = {-1499, -1876, -17718, 0, const WORD16 ixheaacd_mdst_fcoeff_long_kbd_sin[] = {-1499, 1876, -17718, 0, 17718, -1876, 1499}; -const WORD16 *ixheaacd_mdst_fcoeff_longshort_curr[2][2] = { +const WORD16 *const ixheaacd_mdst_fcoeff_longshort_curr[2][2] = { {ixheaacd_mdst_fcoeff_long_sin, ixheaacd_mdst_fcoeff_long_sin_kbd}, {ixheaacd_mdst_fcoeff_long_kbd_sin, ixheaacd_mdst_fcoeff_long_kbd}}; @@ -83,7 +82,7 @@ const WORD16 ixheaacd_mdst_fcoeff_start_sin_kbd[] = {-3433, -3447, -18608, 0, const WORD16 ixheaacd_mdst_fcoeff_start_kbd_sin[] = {-4863, -1525, -19918, 0, 19918, 1525, 4863}; -const WORD16 *ixheaacd_mdst_fcoeff_start_curr[2][2] = { +const WORD16 *const ixheaacd_mdst_fcoeff_start_curr[2][2] = { {ixheaacd_mdst_fcoeff_start_sin, ixheaacd_mdst_fcoeff_start_sin_kbd}, {ixheaacd_mdst_fcoeff_start_kbd_sin, ixheaacd_mdst_fcoeff_start_kbd}}; @@ -96,7 +95,7 @@ const WORD16 ixheaacd_mdst_fcoeff_stop_sin_kbd[] = {-4863, 1525, -19918, 0, const WORD16 ixheaacd_mdst_fcoeff_stop_kbd_sin[] = {-3433, 3447, -18608, 0, 18608, -3447, 3433}; -const WORD16 *ixheaacd_mdst_fcoeff_stop_cur[2][2] = { +const WORD16 *const ixheaacd_mdst_fcoeff_stop_cur[2][2] = { {ixheaacd_mdst_fcoeff_stop_sin, ixheaacd_mdst_fcoeff_stop_sin_kbd}, {ixheaacd_mdst_fcoeff_stop_kbd_sin, ixheaacd_mdst_fcoeff_stop_kbd}}; @@ -109,7 +108,7 @@ const WORD16 ixheaacd_mdst_fcoeff_stopstart_sin_kbd[] = {-6797, -46, -20808, 0, const WORD16 ixheaacd_mdst_fcoeff_stopstart_kbd_sin[] = {-6797, 46, -20808, 0, 20808, 46, 6797}; -const WORD16 *ixheaacd_mdst_fcoeff_stopstart_cur[2][2] = { +const WORD16 *const ixheaacd_mdst_fcoeff_stopstart_cur[2][2] = { {ixheaacd_mdst_fcoeff_stopstart_sin, ixheaacd_mdst_fcoeff_stopstart_sin_kbd}, {ixheaacd_mdst_fcoeff_stopstart_kbd_sin, @@ -125,10 +124,10 @@ const WORD16 ixheaacd_mdst_fcoeff_stop_stopstart_left_sin[] = { const WORD16 ixheaacd_mdst_fcoeff_stop_stopstart_left_kbd[] = { 857, 866, 871, 873, 871, 866, 857}; -const WORD16 *ixheaacd_mdst_fcoeff_l_s_start_left_prev[2] = { +const WORD16 *const ixheaacd_mdst_fcoeff_l_s_start_left_prev[2] = { ixheaacd_mdst_fcoeff_l_s_start_left_sin, ixheaacd_mdst_fcoeff_l_s_start_left_kbd}; -const WORD16 *ixheaacd_mdst_fcoeff_stop_stopstart_left_prev[2] = { +const WORD16 *const ixheaacd_mdst_fcoeff_stop_stopstart_left_prev[2] = { ixheaacd_mdst_fcoeff_stop_stopstart_left_sin, ixheaacd_mdst_fcoeff_stop_stopstart_left_kbd}; @@ -153,7 +152,7 @@ static WORD32 ixheaacd_cplx_pred_data( ia_usac_tmp_core_coder_struct *pstr_core_coder, WORD32 num_window_groups, ia_bit_buf_struct *it_bit_buff) { ia_huff_code_book_struct *ptr_huff_code_book = &ixheaacd_book; - ia_huff_code_word_struct *ptr_huff_code_word = + const ia_huff_code_word_struct *ptr_huff_code_word = ptr_huff_code_book->pstr_huff_code_word; WORD32 cplx_pred_all; WORD32 delta_code_time; @@ -371,14 +370,12 @@ static VOID ixheaacd_filter_and_add(const WORD32 *in, const WORD32 length, out++; for (i = 3; i < length - 4; i += 2) { - sum = 0; - sum = ixheaacd_mac32x32in64_7(sum, &in[i - 3], filter); + sum = ixheaacd_mac32x32in64_7(&in[i - 3], filter); *out = ixheaacd_add32_sat( *out, ixheaacd_sat64_32((((WORD64)sum * (WORD64)factor_odd) >> 15))); out++; - sum = 0; - sum = ixheaacd_mac32x32in64_7(sum, &in[i - 2], filter); + sum = ixheaacd_mac32x32in64_7(&in[i - 2], filter); *out = ixheaacd_add32_sat( *out, ixheaacd_sat64_32((((WORD64)sum * (WORD64)factor_even) >> 15))); out++; diff --git a/decoder/ixheaacd_fft.c b/decoder/ixheaacd_fft.c index fdc2e13..1a784bc 100644 --- a/decoder/ixheaacd_fft.c +++ b/decoder/ixheaacd_fft.c @@ -20,10 +20,10 @@ #include <stdlib.h> #include <stdio.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_interface.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> +#include "ixheaacd_basic_ops32.h" #include "ixheaacd_basic_ops40.h" #include "ixheaacd_function_selector.h" diff --git a/decoder/ixheaacd_freq_sca.c b/decoder/ixheaacd_freq_sca.c index 1694307..efef7b8 100644 --- a/decoder/ixheaacd_freq_sca.c +++ b/decoder/ixheaacd_freq_sca.c @@ -22,15 +22,15 @@ #include <stdlib.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" @@ -39,7 +39,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" @@ -49,13 +49,13 @@ #include "ixheaacd_freq_sca.h" #include "ixheaacd_intrinsics.h" -WORD32 ixheaacd_samp_rate_table[12] = {92017, 75132, 55426, 46009, - 37566, 27713, 23004, 18783, - 13856, 11502, 9391, 16428320}; +const WORD32 ixheaacd_samp_rate_table[12] = {92017, 75132, 55426, 46009, + 37566, 27713, 23004, 18783, + 13856, 11502, 9391, 16428320}; -WORD32 ixheaacd_v_offset_40[16] = {3 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, - 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, - 2 + 1, 2 + 1, 1 + 1, 0}; +const WORD32 ixheaacd_v_offset_40[16] = { + 3 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, + 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 2 + 1, 1 + 1, 0}; static WORD32 ixheaacd_int_div(WORD32 num, WORD32 den) { if (den != 0) { @@ -253,7 +253,7 @@ ixheaacd_calc_stop_band(WORD32 fs, const WORD32 stop_freq, FLOAT32 upsamp_fac) { result = k1_min; for (i = 0; i < stop_freq; i++) { - result = result + arr_diff_stop_freq[i]; + result = ixheaacd_add32_sat(result, arr_diff_stop_freq[i]); } return (result); @@ -401,8 +401,7 @@ WORD16 ixheaacd_calc_master_frq_bnd_tbl( num_bands1 = bands * num_bands1; if (ptr_header_data->alter_scale) { - num_bands1 = num_bands1 * (0x6276); - num_bands1 = num_bands1 >> 15; + num_bands1 = (WORD32)(((WORD64)num_bands1 * (0x6276)) >> 15); } num_bands1 = num_bands1 + 0x1000; @@ -421,10 +420,6 @@ WORD16 ixheaacd_calc_master_frq_bnd_tbl( ixheaacd_aac_shellsort(vec_dk0, num_bands0); - if (vec_dk0[0] == 0) { - return -1; - } - f_master_tbl[0] = k0; for (k = 1; k <= num_bands0; k++) @@ -610,7 +605,7 @@ WORD32 ixheaacd_derive_noise_freq_bnd_tbl( kx = pstr_freq_band_data->freq_band_table[HIGH][0]; if (ptr_header_data->noise_bands == 0) { - pstr_freq_band_data->num_nf_bands = 1; + temp = 1; } else { temp = pstr_common_tables->log_dual_is_table[k2] - pstr_common_tables->log_dual_is_table[kx]; @@ -620,13 +615,12 @@ WORD32 ixheaacd_derive_noise_freq_bnd_tbl( if (temp == 0) { temp = 1; } - pstr_freq_band_data->num_nf_bands = temp; } - pstr_freq_band_data->num_if_bands = pstr_freq_band_data->num_nf_bands; - - if (pstr_freq_band_data->num_nf_bands > MAX_NOISE_COEFFS) { + if (temp > MAX_NOISE_COEFFS) { return -1; } + pstr_freq_band_data->num_nf_bands = temp; + pstr_freq_band_data->num_if_bands = pstr_freq_band_data->num_nf_bands; { WORD16 i_k, k; WORD16 num, den; diff --git a/decoder/ixheaacd_function_selector.h b/decoder/ixheaacd_function_selector.h index 99fc367..daa5aac 100644 --- a/decoder/ixheaacd_function_selector.h +++ b/decoder/ixheaacd_function_selector.h @@ -23,7 +23,7 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_intrinsics.h" @@ -34,7 +34,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -48,7 +48,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" @@ -147,12 +147,14 @@ extern VOID (*ixheaacd_complex_fft_p2)(WORD32 *xr, WORD32 *xi, WORD32 nlength, extern VOID (*ixheaacd_mps_complex_fft_64)(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im, WORD32 nlength); -extern VOID (*ixheaacd_mps_synt_pre_twiddle)(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, +extern VOID (*ixheaacd_mps_synt_pre_twiddle)(WORD32 *ptr_in, + const WORD32 *table_re, + const WORD32 *table_im, WORD32 resolution); -extern VOID (*ixheaacd_mps_synt_post_twiddle)(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, +extern VOID (*ixheaacd_mps_synt_post_twiddle)(WORD32 *ptr_in, + const WORD32 *table_re, + const WORD32 *table_im, WORD32 resolution); extern VOID (*ixheaacd_calc_pre_twid)(WORD32 *ptr_x, WORD32 *r_ptr, @@ -166,8 +168,8 @@ extern VOID (*ixheaacd_calc_post_twid)(WORD32 *ptr_x, WORD32 *r_ptr, const WORD32 *sin_ptr); extern VOID (*ixheaacd_mps_synt_post_fft_twiddle)( - WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state); + WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re, + const WORD32 *table_im, WORD32 *state); extern VOID (*ixheaacd_mps_synt_out_calc)(WORD32 resolution, WORD32 *out, WORD32 *state, const WORD32 *filter_coeff); diff --git a/decoder/ixheaacd_fwd_alias_cnx.c b/decoder/ixheaacd_fwd_alias_cnx.c index 32f50b9..4441dab 100644 --- a/decoder/ixheaacd_fwd_alias_cnx.c +++ b/decoder/ixheaacd_fwd_alias_cnx.c @@ -21,7 +21,7 @@ #include <string.h> #include <math.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" #include "ixheaacd_tns_usac.h" @@ -40,9 +40,8 @@ #include "ixheaacd_arith_dec.h" #include "ixheaacd_windows.h" #include "ixheaacd_constants.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_func_def.h" #include "ixheaacd_acelp_com.h" diff --git a/decoder/ixheaacd_hbe_trans.c b/decoder/ixheaacd_hbe_trans.c index 19c8cbb..a79942a 100644 --- a/decoder/ixheaacd_hbe_trans.c +++ b/decoder/ixheaacd_hbe_trans.c @@ -21,7 +21,7 @@ #include <stdlib.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" @@ -42,7 +42,7 @@ #include "ixheaacd_sbr_const.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_sbr_scale.h" @@ -61,8 +61,8 @@ #include "ixheaacd_qmf_poly.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_op.h" #include "ixheaacd_esbr_rom.h" @@ -576,7 +576,7 @@ VOID ixheaacd_hbe_xprod_proc_4(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, max_n1 = max_n2 = max_trans_fac = 0; for (tr = 1; tr < 4; tr++) { - temp_fac = (2.0f * qmf_band_idx + 1 - tr * p) * 0.25; + temp_fac = (2.0 * qmf_band_idx + 1 - tr * p) * 0.25; n1 = ((WORD32)(temp_fac)) << 1; n2 = ((WORD32)(temp_fac + p)) << 1; @@ -1083,7 +1083,7 @@ VOID ixheaacd_hbe_post_anal_xprod2(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer, WORD32 n1, n2; FLOAT64 temp_fac; FLOAT32 mag_cmplx_gain = 1.666666667f; - temp_fac = (2.0f * qmf_band_idx + 1 - p) * 0.5; + temp_fac = (2.0 * qmf_band_idx + 1 - p) * 0.5; n1 = ((WORD32)(temp_fac)) << 1; n2 = ((WORD32)(temp_fac + p)) << 1; diff --git a/decoder/ixheaacd_headerdecode.c b/decoder/ixheaacd_headerdecode.c index f888798..2ee7201 100644 --- a/decoder/ixheaacd_headerdecode.c +++ b/decoder/ixheaacd_headerdecode.c @@ -18,22 +18,22 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <stdlib.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_error_standards.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops16.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_sbr_common.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_hybrid.h" @@ -488,6 +488,8 @@ WORD32 ixheaacd_ga_hdr_dec(ia_aac_dec_state_struct *aac_state_struct, WORD32 tmp; WORD32 cnt_bits = it_bit_buff->cnt_bits; WORD32 dummy = 0; + UWORD32 aot_init; + ia_audio_specific_config_struct *pstr_audio_specific_config; memset(aac_state_struct->ia_audio_specific_config, 0, @@ -501,6 +503,8 @@ WORD32 ixheaacd_ga_hdr_dec(ia_aac_dec_state_struct *aac_state_struct, aac_state_struct->p_config->str_prog_config.alignment_bits = it_bit_buff->bit_pos; + aot_init = aac_state_struct->audio_object_type; + aac_state_struct->audio_object_type = ixheaacd_read_bits_buf(it_bit_buff, 5); if (aac_state_struct->audio_object_type == 31) { @@ -541,6 +545,10 @@ WORD32 ixheaacd_ga_hdr_dec(ia_aac_dec_state_struct *aac_state_struct, ixheaacd_read_bits_buf(it_bit_buff, 5); } + if (aac_state_struct->ui_init_done) { + if (aac_state_struct->audio_object_type != aot_init) return IA_FATAL_ERROR; + } + if (((aac_state_struct->audio_object_type >= AOT_AAC_MAIN && aac_state_struct->audio_object_type <= AOT_AAC_LTP) || aac_state_struct->audio_object_type == AOT_AAC_SCAL || @@ -997,7 +1005,7 @@ WORD32 ixheaacd_aac_headerdecode( handle_bit_buff = ixheaacd_create_init_bit_buf( &it_bit_buff, (UWORD8 *)(buffer + adts.aac_frame_length), - (WORD16)(header_len - adts.aac_frame_length)); + (WORD16)(header_len - bytes_taken - adts.aac_frame_length)); adts_loc.sync_word = (WORD16)ixheaacd_read_bits_buf(handle_bit_buff, 12); diff --git a/decoder/ixheaacd_huff_code_reorder.c b/decoder/ixheaacd_huff_code_reorder.c index c7ef853..0cc07ed 100644 --- a/decoder/ixheaacd_huff_code_reorder.c +++ b/decoder/ixheaacd_huff_code_reorder.c @@ -19,7 +19,7 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_basic_ops32.h" diff --git a/decoder/ixheaacd_huff_tools.c b/decoder/ixheaacd_huff_tools.c index 5b0d39b..e57bf34 100644 --- a/decoder/ixheaacd_huff_tools.c +++ b/decoder/ixheaacd_huff_tools.c @@ -20,29 +20,18 @@ #include <stdlib.h> #include <stdio.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_interface.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_info.h" #include "ixheaacd_bitbuffer.h" -WORD32 ixheaacd_qsort_cmp(const VOID *va, const VOID *vb) { - const ia_huff_code_word_struct *huff1, *huff2; - - huff1 = (ia_huff_code_word_struct *)va; - huff2 = (ia_huff_code_word_struct *)vb; - if (huff1->len < huff2->len) return -1; - if ((huff1->len == huff2->len) && (huff1->code_word < huff2->code_word)) - return -1; - return 1; -} - VOID ixheaacd_hufftab(ia_huff_code_book_struct *ptr_huff_code_book, - ia_huff_code_word_struct *ptr_huff_code_word, - WORD16 *code_book_tbl, WORD32 *index, WORD32 dim, - WORD32 lav, WORD32 lav_incr_esc, WORD32 sign_code_book, - UWORD8 max_code_word_len) { + const ia_huff_code_word_struct *ptr_huff_code_word, + const WORD16 *code_book_tbl, const WORD32 *index, + WORD32 dim, WORD32 lav, WORD32 lav_incr_esc, + WORD32 sign_code_book, UWORD8 max_code_word_len) { WORD32 i, num; if (!sign_code_book) { @@ -64,14 +53,11 @@ VOID ixheaacd_hufftab(ia_huff_code_book_struct *ptr_huff_code_book, ptr_huff_code_book->code_book_tbl = code_book_tbl; ptr_huff_code_book->idx_tbl = index; ptr_huff_code_book->max_code_word_len = max_code_word_len; - - qsort(ptr_huff_code_word, num, sizeof(ia_huff_code_word_struct), - ixheaacd_qsort_cmp); } -WORD32 ixheaacd_huff_codeword(ia_huff_code_word_struct *ptr_huff_code_word, - UWORD16 data_present, - ia_bit_buf_struct *it_bit_buff) +WORD32 ixheaacd_huff_codeword( + const ia_huff_code_word_struct *ptr_huff_code_word, UWORD16 data_present, + ia_bit_buf_struct *it_bit_buff) { WORD32 i, j; diff --git a/decoder/ixheaacd_hufftables.c b/decoder/ixheaacd_hufftables.c index c9c9232..6cf9e1e 100644 --- a/decoder/ixheaacd_hufftables.c +++ b/decoder/ixheaacd_hufftables.c @@ -19,52 +19,51 @@ */ #include <limits.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_interface.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_info.h" -ia_huff_code_word_struct ixheaacd_huff_book_scl[] = { - - {0, 18, 262120}, {1, 18, 262118}, {2, 18, 262119}, {3, 18, 262117}, - {4, 19, 524277}, {5, 19, 524273}, {6, 19, 524269}, {7, 19, 524278}, - {8, 19, 524270}, {9, 19, 524271}, {10, 19, 524272}, {11, 19, 524284}, - {12, 19, 524285}, {13, 19, 524287}, {14, 19, 524286}, {15, 19, 524279}, - {16, 19, 524280}, {17, 19, 524283}, {18, 19, 524281}, {19, 18, 262116}, - {20, 19, 524282}, {21, 18, 262115}, {22, 17, 131055}, {23, 17, 131056}, - {24, 16, 65525}, {25, 17, 131054}, {26, 16, 65522}, {27, 16, 65523}, - {28, 16, 65524}, {29, 16, 65521}, {30, 15, 32758}, {31, 15, 32759}, - {32, 14, 16377}, {33, 14, 16373}, {34, 14, 16375}, {35, 14, 16371}, - {36, 14, 16374}, {37, 14, 16370}, {38, 13, 8183}, {39, 13, 8181}, - {40, 12, 4089}, {41, 12, 4087}, {42, 12, 4086}, {43, 11, 2041}, - {44, 12, 4084}, {45, 11, 2040}, {46, 10, 1017}, {47, 10, 1015}, - {48, 10, 1013}, {49, 9, 504}, {50, 9, 503}, {51, 8, 250}, - {52, 8, 248}, {53, 8, 246}, {54, 7, 121}, {55, 6, 58}, - {56, 6, 56}, {57, 5, 26}, {58, 4, 11}, {59, 3, 4}, - {60, 1, 0}, {61, 4, 10}, {62, 4, 12}, {63, 5, 27}, - {64, 6, 57}, {65, 6, 59}, {66, 7, 120}, {67, 7, 122}, - {68, 8, 247}, {69, 8, 249}, {70, 9, 502}, {71, 9, 505}, - {72, 10, 1012}, {73, 10, 1014}, {74, 10, 1016}, {75, 11, 2037}, - {76, 11, 2036}, {77, 11, 2038}, {78, 11, 2039}, {79, 12, 4085}, - {80, 12, 4088}, {81, 13, 8180}, {82, 13, 8182}, {83, 13, 8184}, - {84, 14, 16376}, {85, 14, 16372}, {86, 16, 65520}, {87, 15, 32756}, - {88, 16, 65526}, {89, 15, 32757}, {90, 18, 262114}, {91, 19, 524249}, - {92, 19, 524250}, {93, 19, 524251}, {94, 19, 524252}, {95, 19, 524253}, - {96, 19, 524254}, {97, 19, 524248}, {98, 19, 524242}, {99, 19, 524243}, - {100, 19, 524244}, {101, 19, 524245}, {102, 19, 524246}, {103, 19, 524274}, - {104, 19, 524255}, {105, 19, 524263}, {106, 19, 524264}, {107, 19, 524265}, - {108, 19, 524266}, {109, 19, 524267}, {110, 19, 524262}, {111, 19, 524256}, - {112, 19, 524257}, {113, 19, 524258}, {114, 19, 524259}, {115, 19, 524260}, - {116, 19, 524261}, {117, 19, 524247}, {118, 19, 524268}, {119, 19, 524276}, - {120, 19, 524275}}; -WORD32 ixheaacd_book_scl_index[33] = { +const ia_huff_code_word_struct ixheaacd_huff_book_scl[] = { + {60, 1, 0}, {59, 3, 4}, {61, 4, 10}, {58, 4, 11}, + {62, 4, 12}, {57, 5, 26}, {63, 5, 27}, {56, 6, 56}, + {64, 6, 57}, {55, 6, 58}, {65, 6, 59}, {66, 7, 120}, + {54, 7, 121}, {67, 7, 122}, {53, 8, 246}, {68, 8, 247}, + {52, 8, 248}, {69, 8, 249}, {51, 8, 250}, {70, 9, 502}, + {50, 9, 503}, {49, 9, 504}, {71, 9, 505}, {72, 10, 1012}, + {48, 10, 1013}, {73, 10, 1014}, {47, 10, 1015}, {74, 10, 1016}, + {46, 10, 1017}, {76, 11, 2036}, {75, 11, 2037}, {77, 11, 2038}, + {78, 11, 2039}, {45, 11, 2040}, {43, 11, 2041}, {44, 12, 4084}, + {79, 12, 4085}, {42, 12, 4086}, {41, 12, 4087}, {80, 12, 4088}, + {40, 12, 4089}, {81, 13, 8180}, {39, 13, 8181}, {82, 13, 8182}, + {38, 13, 8183}, {83, 13, 8184}, {37, 14, 16370}, {35, 14, 16371}, + {85, 14, 16372}, {33, 14, 16373}, {36, 14, 16374}, {34, 14, 16375}, + {84, 14, 16376}, {32, 14, 16377}, {87, 15, 32756}, {89, 15, 32757}, + {30, 15, 32758}, {31, 15, 32759}, {86, 16, 65520}, {29, 16, 65521}, + {26, 16, 65522}, {27, 16, 65523}, {28, 16, 65524}, {24, 16, 65525}, + {88, 16, 65526}, {25, 17, 131054}, {22, 17, 131055}, {23, 17, 131056}, + {90, 18, 262114}, {21, 18, 262115}, {19, 18, 262116}, {3, 18, 262117}, + {1, 18, 262118}, {2, 18, 262119}, {0, 18, 262120}, {98, 19, 524242}, + {99, 19, 524243}, {100, 19, 524244}, {101, 19, 524245}, {102, 19, 524246}, + {117, 19, 524247}, {97, 19, 524248}, {91, 19, 524249}, {92, 19, 524250}, + {93, 19, 524251}, {94, 19, 524252}, {95, 19, 524253}, {96, 19, 524254}, + {104, 19, 524255}, {111, 19, 524256}, {112, 19, 524257}, {113, 19, 524258}, + {114, 19, 524259}, {115, 19, 524260}, {116, 19, 524261}, {110, 19, 524262}, + {105, 19, 524263}, {106, 19, 524264}, {107, 19, 524265}, {108, 19, 524266}, + {109, 19, 524267}, {118, 19, 524268}, {6, 19, 524269}, {8, 19, 524270}, + {9, 19, 524271}, {10, 19, 524272}, {5, 19, 524273}, {103, 19, 524274}, + {120, 19, 524275}, {119, 19, 524276}, {4, 19, 524277}, {7, 19, 524278}, + {15, 19, 524279}, {16, 19, 524280}, {18, 19, 524281}, {20, 19, 524282}, + {17, 19, 524283}, {11, 19, 524284}, {12, 19, 524285}, {14, 19, 524286}, + {13, 19, 524287}}; +const WORD32 ixheaacd_book_scl_index[33] = { 0x00000000, 0x10100004, 0x2040000c, 0x00a0003b, 0x30d0007a, 0x412000fa, 0x516001f9, 0x61c003f9, 0x722007f9, 0x82800ff9, 0x92d01ff8, 0xa3503ff9, 0xb400fff6, 0xc431fff0, 0x0687ffef, 0x0707fff7, 0x0747fffb, 0x0767fffd, 0x0777fffe, 0x0787ffff, 0x0030000b, 0x0060001b, 0x00f000f7, 0x014001f7, 0x01a003f7, 0x020007f7, 0x02600ff7, 0x02c01ff7, 0x03303ff7, 0x03907ff7, 0x0421ffef, 0x14a3ffe8, 0x0587ffdf}; -WORD16 ixheaacd_book_scl_code_book[122] = { +const WORD16 ixheaacd_book_scl_code_book[122] = { 0x0013, 0x0781, 0x0763, 0x07a4, 0x0744, 0x07c4, 0x0725, 0x07e5, 0x0706, 0x0806, 0x06e6, 0x0826, 0x0847, 0x06c7, 0x0867, 0x06a8, 0x0888, 0x0688, 0x08a8, 0x0668, 0x08c9, 0x0649, 0x0629, 0x08e9, 0x090a, 0x060a, 0x092a, diff --git a/decoder/ixheaacd_hybrid.c b/decoder/ixheaacd_hybrid.c index 3dcaa92..49e846a 100644 --- a/decoder/ixheaacd_hybrid.c +++ b/decoder/ixheaacd_hybrid.c @@ -19,15 +19,15 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" @@ -37,7 +37,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" diff --git a/decoder/ixheaacd_imdct.c b/decoder/ixheaacd_imdct.c index 02929b0..d162cea 100644 --- a/decoder/ixheaacd_imdct.c +++ b/decoder/ixheaacd_imdct.c @@ -22,8 +22,8 @@ #include <stdlib.h> #include <string.h> -#include <ixheaacd_type_def.h> -#include <ixheaacd_interface.h> +#include "ixheaacd_type_def.h" +#include "ixheaacd_interface.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" @@ -49,9 +49,8 @@ #include "ixheaacd_vec_baisc_ops.h" #include "ixheaacd_constants.h" #include "ixheaacd_function_selector.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_func_def.h" @@ -197,19 +196,23 @@ void ixheaacd_acelp_imdct(WORD32 *imdct_in, WORD32 npoints, WORD8 *qshift, WORD8 ixheaacd_cal_fac_data(ia_usac_data_struct *usac_data, WORD32 i_ch, WORD32 n_long, WORD32 lfac, WORD32 *fac_idata) { WORD32 gain_fac, scale, k, *i_aq, itemp = 0, *izir; - WORD32 int_aq[ORDER + 1], intzir[2 * LEN_FRAME], x_in[FAC_LENGTH]; + WORD32 int_aq[ORDER + 1] = {0}; + WORD32 intzir[2 * LEN_FRAME] = {0}; + WORD32 x_in[FAC_LENGTH] = {0}; FLOAT32 gain, ztemp, ftemp, pow10, rem10; FLOAT32 qfac1; - WORD8 qshift1, qshift2 = 0, qshift3 = 0; - WORD32 quo, rem, preshift = 0; + WORD8 qshift1 = 0; + WORD8 qshift2 = 0; + WORD8 qshift3 = 0; + WORD32 preshift = 0; FLOAT32 *last_lpc = usac_data->lpc_prev[i_ch]; FLOAT32 *acelp_in = usac_data->acelp_in[i_ch]; WORD32 *fac_data = usac_data->fac_data[i_ch]; WORD32 *ptr_scratch = &usac_data->scratch_buffer[0]; - quo = fac_data[0] / 28; - rem = fac_data[0] % 28; + WORD32 quo = fac_data[0] / 28; + WORD32 rem = fac_data[0] % 28; pow10 = ixheaacd_pow10(quo); rem10 = (FLOAT32)ixheaacd_power_10_table[rem]; @@ -483,13 +486,13 @@ static WORD32 ixheaacd_fd_imdct_long(ia_usac_data_struct *usac_data, for (i = 0; i < ixheaacd_drc_offset->n_long / 2; i++) { p_overlap_ibuffer[ixheaacd_drc_offset->n_long / 2 + i] = - -p_in_ibuffer[i] >> (shiftp - shift_olap); + ixheaacd_negate32_sat(p_in_ibuffer[i]) >> (shiftp - shift_olap); p_overlap_ibuffer[ixheaacd_drc_offset->n_long / 2 - i - 1] = - -p_in_ibuffer[i] >> (shiftp - shift_olap); + ixheaacd_negate32_sat(p_in_ibuffer[i]) >> (shiftp - shift_olap); } - ixheaacd_scale_down(p_out_ibuffer, p_out_ibuffer, ixheaacd_drc_offset->n_long, - output_q, 15); + ixheaacd_scale_down_adj(p_out_ibuffer, p_out_ibuffer, + ixheaacd_drc_offset->n_long, output_q, 15); if (td_frame_prev) { qfac = 1.0f / (FLOAT32)(1 << 15); @@ -550,4 +553,4 @@ WORD32 ixheaacd_fd_frm_dec(ia_usac_data_struct *usac_data, WORD32 i_ch) { fac_q); return 0; -}
\ No newline at end of file +} diff --git a/decoder/ixheaacd_info.h b/decoder/ixheaacd_info.h index d6de7eb..3f4d485 100644 --- a/decoder/ixheaacd_info.h +++ b/decoder/ixheaacd_info.h @@ -61,9 +61,9 @@ typedef struct { WORD32 off; WORD32 sign_code_book; UWORD16 max_code_word_len; - ia_huff_code_word_struct *pstr_huff_code_word; - WORD16 *code_book_tbl; - WORD32 *idx_tbl; + const ia_huff_code_word_struct *pstr_huff_code_word; + const WORD16 *code_book_tbl; + const WORD32 *idx_tbl; } ia_huff_code_book_struct; typedef struct { @@ -98,12 +98,13 @@ typedef struct { extern ia_huff_code_book_struct ixheaacd_book; VOID ixheaacd_hufftab(ia_huff_code_book_struct *ptr_huff_code_book, - ia_huff_code_word_struct *ptr_huff_code_word, - WORD16 *code_book_tbl, WORD32 *index, WORD32 dim, - WORD32 lav, WORD32 lav_incr_esc, WORD32 sign_code_book, - UWORD8 max_code_word_len); + const ia_huff_code_word_struct *ptr_huff_code_word, + const WORD16 *code_book_tbl, const WORD32 *index, + WORD32 dim, WORD32 lav, WORD32 lav_incr_esc, + WORD32 sign_code_book, UWORD8 max_code_word_len); -WORD32 ixheaacd_huff_codeword(ia_huff_code_word_struct *h, UWORD16 data_present, +WORD32 ixheaacd_huff_codeword(const ia_huff_code_word_struct *h, + UWORD16 data_present, ia_bit_buf_struct *it_bit_buff); #endif /* IXHEAACD_INFO_H */ diff --git a/decoder/ixheaacd_init_config.c b/decoder/ixheaacd_init_config.c index 9efd983..fc2dd09 100644 --- a/decoder/ixheaacd_init_config.c +++ b/decoder/ixheaacd_init_config.c @@ -22,7 +22,7 @@ #include <stdarg.h> #include <assert.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" @@ -32,7 +32,7 @@ #include "ixheaacd_env_extr_part.h" #include "ixheaacd_aac_rom.h" #include "ixheaacd_common_rom.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -66,6 +66,11 @@ #include "ixheaacd_error_codes.h" +static const WORD32 sampling_rate_tbl[] = { + 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, + 8000, 7350, 0, 0, 57600, 51200, 40000, 38400, 34150, 28800, 25600, + 20000, 19200, 17075, 14400, 12800, 9600, 0, 0, 0}; + UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_framelength_idx) { UWORD32 sbr_ratio_index = 0x0FF; @@ -88,22 +93,13 @@ UWORD32 ixheaacd_sbr_ratio(UWORD32 core_sbr_framelength_idx) { return sbr_ratio_index; } -WORD32 ixheaacd_get_sample_freq_indx(WORD32 sampling_freq) { - WORD32 sampling_rate_tbl[] = {96000, 88200, 64000, 48000, 44100, 32000, - 24000, 22050, 16000, 12000, 11025, 8000, - 7350, 0, 0, 0}; - +static WORD32 ixheaacd_get_sample_freq_indx(WORD32 sampling_freq) { WORD32 index; - WORD32 tbl_size = sizeof(sampling_rate_tbl) / sizeof(WORD32) - 1; + const WORD32 tbl_size = sizeof(sampling_rate_tbl) / sizeof(WORD32) - 1; for (index = 0; index < tbl_size; index++) { if (sampling_rate_tbl[index] == sampling_freq) break; } - - if (index > tbl_size) { - return tbl_size - 1; - } - return index; } UWORD32 ixheaacd_sbr_params(UWORD32 core_sbr_framelength_idx, @@ -192,6 +188,11 @@ static VOID ixheaacd_get_usac_chan_conf(ia_usac_config_struct *pstr_usac_config, pstr_usac_config->output_channel_pos[0] = BS_OUTPUT_CHANNEL_POS_L; pstr_usac_config->output_channel_pos[1] = BS_OUTPUT_CHANNEL_POS_R; break; + case 8: + pstr_usac_config->num_out_channels = 2; + pstr_usac_config->output_channel_pos[0] = BS_OUTPUT_CHANNEL_POS_NA; + pstr_usac_config->output_channel_pos[1] = BS_OUTPUT_CHANNEL_POS_NA; + break; default: assert(0); @@ -292,7 +293,7 @@ WORD32 ixheaacd_ext_element_config( return 0; } -VOID ixheaacd_mps212_config( +IA_ERRORCODE ixheaacd_mps212_config( ia_bit_buf_struct *it_bit_buff, ia_usac_dec_mps_config_struct *pstr_usac_mps212_config, WORD32 stereo_config_index) { @@ -306,6 +307,8 @@ VOID ixheaacd_mps212_config( pstr_usac_mps212_config->bs_decorr_config = ixheaacd_read_bits_buf(it_bit_buff, 2); + if (pstr_usac_mps212_config->bs_decorr_config > MAX_DECOR_CONFIG_IDX) + return IA_FATAL_ERROR; pstr_usac_mps212_config->bs_high_rate_mode = ixheaacd_read_bits_buf(it_bit_buff, 1); @@ -319,12 +322,17 @@ VOID ixheaacd_mps212_config( if (pstr_usac_mps212_config->bs_ott_bands_phase_present) { pstr_usac_mps212_config->bs_ott_bands_phase = ixheaacd_read_bits_buf(it_bit_buff, 5); + if (pstr_usac_mps212_config->bs_ott_bands_phase > MAX_PARAMETER_BANDS) + return IA_FATAL_ERROR; } if (stereo_config_index > 1) { pstr_usac_mps212_config->bs_residual_bands = ixheaacd_read_bits_buf(it_bit_buff, 5); + if (pstr_usac_mps212_config->bs_residual_bands > MAX_PARAMETER_BANDS) + return IA_FATAL_ERROR; + pstr_usac_mps212_config->bs_ott_bands_phase = max(pstr_usac_mps212_config->bs_ott_bands_phase, pstr_usac_mps212_config->bs_residual_bands); @@ -336,9 +344,11 @@ VOID ixheaacd_mps212_config( if (pstr_usac_mps212_config->bs_temp_shape_config == 2) pstr_usac_mps212_config->bs_env_quant_mode = ixheaacd_read_bits_buf(it_bit_buff, 1); + + return IA_NO_ERROR; } -VOID ixheaacd_cpe_config( +IA_ERRORCODE ixheaacd_cpe_config( ia_bit_buf_struct *it_bit_buff, ia_usac_dec_element_config_struct *pstr_usac_element_config, WORD32 sbr_ratio_index) { @@ -357,9 +367,11 @@ VOID ixheaacd_cpe_config( } if (pstr_usac_element_config->stereo_config_index > 0) - ixheaacd_mps212_config(it_bit_buff, - &(pstr_usac_element_config->str_usac_mps212_config), - pstr_usac_element_config->stereo_config_index); + return ixheaacd_mps212_config( + it_bit_buff, &(pstr_usac_element_config->str_usac_mps212_config), + pstr_usac_element_config->stereo_config_index); + + return IA_NO_ERROR; } WORD32 ixheaacd_decoder_config( @@ -393,7 +405,7 @@ WORD32 ixheaacd_decoder_config( ixheaacd_read_bits_buf(it_bit_buff, 1); pstr_usac_element_config->noise_filling = ixheaacd_read_bits_buf(it_bit_buff, 1); - + pstr_usac_element_config->stereo_config_index = 0; if (sbr_ratio_index > 0) ixheaacd_sbr_config(it_bit_buff, &(pstr_usac_element_config->str_usac_sbr_config)); @@ -401,8 +413,9 @@ WORD32 ixheaacd_decoder_config( break; case ID_USAC_CPE: - ixheaacd_cpe_config(it_bit_buff, pstr_usac_element_config, - sbr_ratio_index); + if (ixheaacd_cpe_config(it_bit_buff, pstr_usac_element_config, + sbr_ratio_index) != IA_NO_ERROR) + return IA_FATAL_ERROR; if (pstr_usac_element_config->stereo_config_index > 1 && *chan < 2) return -1; @@ -412,6 +425,7 @@ WORD32 ixheaacd_decoder_config( pstr_usac_element_config->tw_mdct = 0; pstr_usac_element_config->noise_filling = 0; + pstr_usac_element_config->stereo_config_index = 0; break; case ID_USAC_EXT: @@ -462,6 +476,8 @@ WORD32 ixheaacd_config_extension( ixheaacd_read_escape_value(it_bit_buff, &(usac_config_ext_type), 4, 8, 16); ixheaacd_read_escape_value(it_bit_buff, &(usac_config_ext_len), 4, 8, 16); + if (usac_config_ext_len > 768) return IA_FATAL_ERROR; + switch (usac_config_ext_type) { case ID_CONFIG_EXT_FILL: for (i = 0; i < usac_config_ext_len; i++) { @@ -509,12 +525,6 @@ WORD32 ixheaacd_config(ia_bit_buf_struct *it_bit_buff, } } else { - static const WORD32 sampling_rate_tbl[] = { - 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, - 16000, 12000, 11025, 8000, 7350, 0, 0, 57600, - 51200, 40000, 38400, 34150, 28800, 25600, 20000, 19200, - 17075, 14400, 12800, 9600, 0, 0, 0}; - pstr_usac_conf->usac_sampling_frequency = sampling_rate_tbl[pstr_usac_conf->usac_sampling_frequency_index]; } @@ -527,7 +537,9 @@ WORD32 ixheaacd_config(ia_bit_buf_struct *it_bit_buff, pstr_usac_conf->channel_configuration_index = ixheaacd_read_bits_buf(it_bit_buff, 5); - if (pstr_usac_conf->channel_configuration_index >= 3) return -1; + if ((pstr_usac_conf->channel_configuration_index >= 3) && + (pstr_usac_conf->channel_configuration_index != 8)) + return -1; if (pstr_usac_conf->channel_configuration_index == 0) { UWORD32 i; diff --git a/decoder/ixheaacd_initfuncs.c b/decoder/ixheaacd_initfuncs.c index e95f504..c00dc74 100644 --- a/decoder/ixheaacd_initfuncs.c +++ b/decoder/ixheaacd_initfuncs.c @@ -18,23 +18,23 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_sbr_common.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops16.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_bitbuffer.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_definitions.h" @@ -56,13 +56,10 @@ #include "ixheaacd_sbr_payload.h" #include "ixheaacd_common_rom.h" - -#include <ixheaacd_type_def.h> - #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_hybrid.h" diff --git a/decoder/ixheaacd_interface.h b/decoder/ixheaacd_interface.h index 07f7963..4a9c263 100644 --- a/decoder/ixheaacd_interface.h +++ b/decoder/ixheaacd_interface.h @@ -71,17 +71,22 @@ VOID ixheaacd_complex_ifft_p2_asm(const WORD32 *table, WORD32 nlength, VOID ixheaacd_complex_fft_p2_asm(const WORD32 *table, WORD32 nlength, WORD32 *ptr_x, WORD32 *ptr_y); -VOID ixheaacd_mps_synt_pre_twiddle_dec(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, WORD32 resolution); +VOID ixheaacd_mps_synt_pre_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 resolution); -VOID ixheaacd_mps_synt_pre_twiddle_armv7(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, WORD32 resolution); +VOID ixheaacd_mps_synt_pre_twiddle_armv7(WORD32 *ptr_in, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 resolution); -VOID ixheaacd_mps_synt_post_twiddle_dec(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, WORD32 resolution); +VOID ixheaacd_mps_synt_post_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 resolution); -VOID ixheaacd_mps_synt_post_twiddle_armv7(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, WORD32 resolution); +VOID ixheaacd_mps_synt_post_twiddle_armv7(WORD32 *ptr_in, + const WORD32 *table_re, + const WORD32 *table_im, + WORD32 resolution); VOID ixheaacd_calc_pre_twid_dec(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength, const WORD32 *cos_ptr, @@ -100,12 +105,16 @@ VOID ixheaacd_calc_post_twid_armv7(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, const WORD32 *sin_ptr); VOID ixheaacd_mps_synt_post_fft_twiddle_dec(WORD32 resolution, WORD32 *fin_re, - WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state); + WORD32 *fin_im, + const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state); VOID ixheaacd_mps_synt_post_fft_twiddle_armv7(WORD32 resolution, WORD32 *fin_re, - WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state); + WORD32 *fin_im, + const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state); VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, WORD32 *out, WORD32 *state, const WORD32 *filter_coeff); diff --git a/decoder/ixheaacd_latmdemux.c b/decoder/ixheaacd_latmdemux.c index 09c609d..ecceb04 100644 --- a/decoder/ixheaacd_latmdemux.c +++ b/decoder/ixheaacd_latmdemux.c @@ -19,7 +19,7 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_basic_ops32.h" #include "ixheaacd_basic_ops16.h" @@ -27,7 +27,7 @@ #include "ixheaacd_basic_ops.h" #include "ixheaacd_bitbuffer.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_defines.h" @@ -53,9 +53,6 @@ #include "ixheaacd_sbr_payload.h" #include "ixheaacd_common_rom.h" - -#include <ixheaacd_type_def.h> - #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_env_extr_part.h" diff --git a/decoder/ixheaacd_longblock.c b/decoder/ixheaacd_longblock.c index 7ac686b..432e3db 100644 --- a/decoder/ixheaacd_longblock.c +++ b/decoder/ixheaacd_longblock.c @@ -18,18 +18,18 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_bitbuffer.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_pulsedata.h" diff --git a/decoder/ixheaacd_lpc.c b/decoder/ixheaacd_lpc.c index a1c9fb6..0dec734 100644 --- a/decoder/ixheaacd_lpc.c +++ b/decoder/ixheaacd_lpc.c @@ -24,7 +24,7 @@ #include <math.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" #include "ixheaacd_tns_usac.h" @@ -46,8 +46,8 @@ #include "ixheaacd_windows.h" #include "ixheaacd_acelp_com.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #define LSF_GAP_F 50.0f #define FREQ_MAX_F 6400.0f @@ -57,7 +57,7 @@ extern const FLOAT32 lsf_init[ORDER]; extern const FLOAT32 ixheaacd_fir_lp_filt[1 + FILTER_DELAY]; -WORD32 ixheaacd_pow_10_i_by_128[128] = { +const WORD32 ixheaacd_pow_10_i_by_128[128] = { 16384, 17788, 19312, 20968, 22765, 24716, 26835, 29135, 31632, 34343, 37287, 40483, 43953, 47720, 51810, 56251, 61072, 66307, 71990, 78161, 84860, @@ -137,6 +137,19 @@ void ixheaacd_reset_acelp_data_fix(ia_usac_data_struct *usac_data, for (i = 0; i < (usac_data->ccfl) / 2 - fac_length; i++) { ptr_overlap_buf[(usac_data->ccfl) / 2 + fac_length + i] = 0; } + + if (ptr_overlap_buf != NULL) { + for (i = 0; i < (usac_data->len_subfrm) / 2 - fac_length; i++) { + st->exc_prev[i] = 0.0f; + } + for (i = 0; i < 2 * fac_length + 1; i++) { + st->exc_prev[(usac_data->len_subfrm) / 2 - fac_length + i] = + ptr_overlap_buf[i + usac_data->ccfl / 2 - fac_length - 1] / + (float)(16384); + } + } else { + ixheaacd_memset(st->exc_prev, 1 + (2 * FAC_LENGTH)); + } } return; @@ -155,7 +168,6 @@ VOID ixheaacd_fix2flt_data(ia_usac_data_struct *usac_data, } ixheaacd_memset(st->lp_flt_coeff_a_prev, 2 * (ORDER + 1)); - ixheaacd_memset(st->exc_prev, 1 + (2 * FAC_LENGTH)); ixheaacd_memset(st->xcitation_prev, MAX_PITCH + INTER_LP_FIL_ORDER + 1); ixheaacd_memset(st->synth_prev, MAX_PITCH + SYNTH_DELAY_LMAX); ixheaacd_memset(st->bpf_prev, FILTER_DELAY + LEN_SUBFR); @@ -421,10 +433,10 @@ WORD32 ixheaacd_lpd_dec(ia_usac_data_struct *usac_data, memcpy(ptr_scratch, &pstr_td_frame_data->fac_data[0], 129 * sizeof(WORD32)); - for (i = 0; i < 64; i++) { + for (i = 0; i < fac_length / 2; i++) { pstr_td_frame_data->fac_data[i] = ptr_scratch[2 * i + 1] << 16; - pstr_td_frame_data->fac_data[64 + i] = ptr_scratch[fac_length - 2 * i] - << 16; + pstr_td_frame_data->fac_data[fac_length / 2 + i] = + ptr_scratch[fac_length - 2 * i] << 16; } err = ixheaacd_fwd_alias_cancel_tool(usac_data, pstr_td_frame_data, @@ -707,7 +719,7 @@ WORD32 ixheaacd_lpd_bpf_fix(ia_usac_data_struct *usac_data, err = ixheaacd_bass_post_filter(synth, pitch, pitch_gain, signal_out, (lpd_sbf_len + 2) * LEN_SUBFR + LEN_SUBFR, - len_fr - (lpd_sbf_len + 2) * LEN_SUBFR, + len_fr - (lpd_sbf_len + 4) * LEN_SUBFR, st->bpf_prev); if (err != 0) return err; diff --git a/decoder/ixheaacd_lpc_dec.c b/decoder/ixheaacd_lpc_dec.c index f7c8892..3dda040 100644 --- a/decoder/ixheaacd_lpc_dec.c +++ b/decoder/ixheaacd_lpc_dec.c @@ -17,10 +17,8 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#define DEBUG - #include <math.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" #include "ixheaacd_tns_usac.h" @@ -38,16 +36,16 @@ #include "ixheaacd_func_def.h" #include "ixheaacd_acelp_com.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #define LSF_GAP 50.0f #define FREQ_MAX 6400.0f #define FREQ_DIV 400.0f -static FLOAT32 factor_table[4] = {60.0f, 65.0f, 64.0f, 63.0f}; +static const FLOAT32 factor_table[4] = {60.0f, 65.0f, 64.0f, 63.0f}; VOID ixheaacd_lsf_weight_2st_flt(FLOAT32 *lsfq, FLOAT32 *w, WORD32 mode) { WORD32 i; @@ -102,12 +100,12 @@ static WORD32 ixheaacd_decoding_avq_tool(WORD32 *read_arr, WORD32 *nvecq) { static WORD32 ixheaacd_avq_first_approx_abs(FLOAT32 *lsf, WORD32 *indx) { WORD32 i; - extern FLOAT32 ixheaacd_dico_lsf_abs_8b_flt[]; - extern FLOAT32 ixheaacd_weight_table_avq[]; + extern const FLOAT32 ixheaacd_dico_lsf_abs_8b_flt[]; + extern const FLOAT32 ixheaacd_weight_table_avq[]; WORD32 position = 0; WORD32 avq[ORDER]; FLOAT32 d[ORDER + 1], lsf_min; - FLOAT32 *ptr_w; + const FLOAT32 *ptr_w; ptr_w = &ixheaacd_weight_table_avq[(indx[0] * ORDER)]; @@ -241,4 +239,4 @@ VOID ixheaacd_alg_vec_dequant(ia_td_frame_data_struct *pstr_td_frame_data, lpc_index += pos; } -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_lpfuncs.c b/decoder/ixheaacd_lpfuncs.c index 5a83aac..44433a0 100644 --- a/decoder/ixheaacd_lpfuncs.c +++ b/decoder/ixheaacd_lpfuncs.c @@ -19,21 +19,21 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_bitbuffer.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_definitions.h" @@ -56,13 +56,10 @@ #include "ixheaacd_sbr_payload.h" #include "ixheaacd_common_rom.h" - -#include <ixheaacd_type_def.h> - #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_sbr_scale.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_hybrid.h" diff --git a/decoder/ixheaacd_lpp_tran.c b/decoder/ixheaacd_lpp_tran.c index 95d60e5..f096825 100644 --- a/decoder/ixheaacd_lpp_tran.c +++ b/decoder/ixheaacd_lpp_tran.c @@ -20,15 +20,15 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" @@ -40,7 +40,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -54,7 +54,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" @@ -541,18 +541,18 @@ static PLATFORM_INLINE VOID ixheaacd_filt_step3_lp(WORD len, WORD32 coef1, WORD32 temp = ixheaacd_mult32x16hin32(prev2, coef2); pqmf_real_low += 64; - *pqmf_real_high = - ixheaacd_add32((curr >> LPC_SCALE_FACTOR), - ((ixheaacd_mac32x16hin32(temp, prev1, coef1)) << 1)); + *pqmf_real_high = ixheaacd_add32_sat( + (curr >> LPC_SCALE_FACTOR), + (ixheaacd_shl32_sat(ixheaacd_mac32x16hin32(temp, prev1, coef1), 1))); pqmf_real_high += 64; prev2 = *pqmf_real_low; temp = ixheaacd_mult32x16hin32(prev1, coef2); pqmf_real_low += 64; - *pqmf_real_high = - ixheaacd_add32((prev2 >> LPC_SCALE_FACTOR), - ((ixheaacd_mac32x16hin32(temp, curr, coef1)) << 1)); + *pqmf_real_high = ixheaacd_add32_sat( + (prev2 >> LPC_SCALE_FACTOR), + (ixheaacd_shl32_sat(ixheaacd_mac32x16hin32(temp, curr, coef1), 1))); pqmf_real_high += 64; prev1 = prev2; @@ -957,8 +957,8 @@ VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, max_val = ixheaacd_add32_sat( max_val, ixheaacd_mult32(cov_matrix.phi_12_im, cov_matrix.phi_12_im)); - v = ixheaacd_sub32(ixheaacd_mult32(cov_matrix.phi_11, cov_matrix.phi_22), - max_val) + v = ixheaacd_sub32_sat( + ixheaacd_mult32(cov_matrix.phi_11, cov_matrix.phi_22), max_val) << 1; cov_matrix.d = v; @@ -978,8 +978,8 @@ VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, modulus_d = ixheaacd_abs32_sat(cov_matrix.d); tmp_r = - (ixheaacd_sub32( - ixheaacd_sub32( + (ixheaacd_sub32_sat( + ixheaacd_sub32_sat( ixheaacd_mult32(cov_matrix.phi_01, cov_matrix.phi_12), ixheaacd_mult32(cov_matrix.phi_01_im, cov_matrix.phi_12_im)), ixheaacd_mult32(cov_matrix.phi_02, cov_matrix.phi_11))) >> @@ -1022,12 +1022,12 @@ VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, inverse_r11 = (WORD16)(*ixheaacd_fix_div)( 0x40000000, (cov_matrix.phi_11 << norm_r11)); - tmp_r = ixheaacd_add32( + tmp_r = ixheaacd_add32_sat( ixheaacd_add32( (cov_matrix.phi_01 >> (LPC_SCALE_FACTOR + 1)), ixheaacd_mult32x16in32(cov_matrix.phi_12, alpha_real[1])), ixheaacd_mult32x16in32(cov_matrix.phi_12_im, alpha_imag[1])); - tmp_i = ixheaacd_sub32( + tmp_i = ixheaacd_sub32_sat( ixheaacd_add32( (cov_matrix.phi_01_im >> (LPC_SCALE_FACTOR + 1)), ixheaacd_mult32x16in32(cov_matrix.phi_12, alpha_imag[1])), @@ -1058,13 +1058,13 @@ VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, } } - if (ixheaacd_add32((alpha_real[0] * alpha_real[0]), - (alpha_imag[0] * alpha_imag[0])) >= 0x40000000L) { + if (ixheaacd_add32_sat((alpha_real[0] * alpha_real[0]), + (alpha_imag[0] * alpha_imag[0])) >= 0x40000000L) { reset_lpc_coeff = 1; } - if (ixheaacd_add32((alpha_real[1] * alpha_real[1]), - (alpha_imag[1] * alpha_imag[1])) >= 0x40000000L) { + if (ixheaacd_add32_sat((alpha_real[1] * alpha_real[1]), + (alpha_imag[1] * alpha_imag[1])) >= 0x40000000L) { reset_lpc_coeff = 1; } @@ -1091,9 +1091,11 @@ VOID ixheaacd_hf_generator(ia_sbr_hf_generator_struct *hf_generator, continue; } - while (high_band >= - hf_generator->pstr_settings->bw_borders[bw_index[patch]]) { - bw_index[patch] = (bw_index[patch] + 1); + while ((bw_index[patch] < MAX_NUM_PATCHES - 1) && + (bw_index[patch] < MAX_NUM_NOISE_VALUES) && + (high_band >= + hf_generator->pstr_settings->bw_borders[bw_index[patch]])) { + bw_index[patch]++; } bw = ixheaacd_extract16h(bw_array[bw_index[patch]]); diff --git a/decoder/ixheaacd_lt_predict.c b/decoder/ixheaacd_lt_predict.c index 8d00bc8..83fc9cc 100644 --- a/decoder/ixheaacd_lt_predict.c +++ b/decoder/ixheaacd_lt_predict.c @@ -22,14 +22,14 @@ #include <stdio.h> #include <string.h> -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_audioobjtypes.h" #include "ixheaacd_bitbuffer.h" diff --git a/decoder/ixheaacd_mps_dec.c b/decoder/ixheaacd_mps_dec.c index 3540e55..407abef 100644 --- a/decoder/ixheaacd_mps_dec.c +++ b/decoder/ixheaacd_mps_dec.c @@ -19,8 +19,12 @@ */ #include <stdlib.h> #include <stdio.h> +#include <math.h> -#include <ixheaacd_type_def.h> +#include <assert.h> +#include <string.h> + +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" @@ -28,9 +32,9 @@ #include "ixheaacd_memory_standards.h" #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_common_rom.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -65,19 +69,15 @@ #include "ixheaacd_mps_hybfilter.h" #include "ixheaacd_mps_nlc_dec.h" #include "ixheaacd_mps_huff_tab.h" +#include "ixheaacd_error_standards.h" -#include "math.h" - -#include <assert.h> -#include <string.h> - -extern ia_huff_pt0_nodes_struct ixheaacd_huff_part0_nodes; -extern ia_huff_ipd_nodes_struct ixheaacd_huff_ipd_nodes; -extern ia_huff_lav_nodes_struct ixheaacd_huff_lav_idx_nodes; -extern ia_huff_pt0_nodes_struct ixheaacd_huff_pilot_nodes; -extern ia_huff_cld_nodes_struct ixheaacd_huff_cld_nodes; -extern ia_huff_icc_nodes_struct ixheaacd_huff_icc_nodes; -extern ia_huff_res_nodes_struct ixheaacd_huff_reshape_nodes; +extern const ia_huff_pt0_nodes_struct ixheaacd_huff_part0_nodes; +extern const ia_huff_ipd_nodes_struct ixheaacd_huff_ipd_nodes; +extern const ia_huff_lav_nodes_struct ixheaacd_huff_lav_idx_nodes; +extern const ia_huff_pt0_nodes_struct ixheaacd_huff_pilot_nodes; +extern const ia_huff_cld_nodes_struct ixheaacd_huff_cld_nodes; +extern const ia_huff_icc_nodes_struct ixheaacd_huff_icc_nodes; +extern const ia_huff_res_nodes_struct ixheaacd_huff_reshape_nodes; WORD32 ixheaacd_mps_create(ia_mps_dec_state_struct* self, WORD32 bs_frame_len, WORD32 residual_coding, @@ -126,8 +126,9 @@ WORD32 ixheaacd_mps_create(ia_mps_dec_state_struct* self, WORD32 bs_frame_len, if ((self->residual_coding) && (self->res_bands > 0)) ixheaacd_mps_qmf_hybrid_analysis_init(&self->hyb_filt_state[1]); - ixheaacd_mps_decor_init(&(self->mps_decor), self->hyb_band_count, - self->config->bs_decorr_config); + err_code = ixheaacd_mps_decor_init(&(self->mps_decor), self->hyb_band_count, + self->config->bs_decorr_config); + if (err_code != IA_NO_ERROR) return err_code; ixheaacd_mps_init_pre_and_post_matrix(self); @@ -152,11 +153,11 @@ WORD32 ixheaacd_mps_create(ia_mps_dec_state_struct* self, WORD32 bs_frame_len, return 0; } -static FLOAT32 ixheaacd_tsd_mul_re[] = { +static const FLOAT32 ixheaacd_tsd_mul_re[] = { 1.0f, 0.707106781186548f, 0.0f, -0.707106781186548f, -1.0f, -0.707106781186548f, 0.0f, 0.707106781186548f}; -static FLOAT32 ixheaacd_tsd_mul_im[] = { +static const FLOAT32 ixheaacd_tsd_mul_im[] = { 0.0f, 0.707106781186548f, 1.0f, 0.707106781186548f, 0.0f, -0.707106781186548f, -1.0f, -0.707106781186548f}; diff --git a/decoder/ixheaacd_mps_dec.h b/decoder/ixheaacd_mps_dec.h index 527cb2e..845b723 100644 --- a/decoder/ixheaacd_mps_dec.h +++ b/decoder/ixheaacd_mps_dec.h @@ -60,8 +60,8 @@ typedef struct ia_mps_decor_filt_struct { WORD32 den_len; ia_cmplx_flt_struct state[MAX_DECORR_FIL_ORDER + 1]; - FLOAT32 *num; - FLOAT32 *den; + const FLOAT32 *num; + const FLOAT32 *den; } ia_mps_decor_filt_struct; @@ -200,7 +200,7 @@ typedef struct ia_mps_dec_state_struct { WORD32 qmf_band_count; WORD32 hyb_band_count; - WORD32 *hyb_band_to_processing_band_table; + const WORD32 *hyb_band_to_processing_band_table; WORD32 res_ch_count; diff --git a/decoder/ixheaacd_mps_decor.h b/decoder/ixheaacd_mps_decor.h index 3d9f6df..4f856f5 100644 --- a/decoder/ixheaacd_mps_decor.h +++ b/decoder/ixheaacd_mps_decor.h @@ -24,7 +24,7 @@ #define ONE_MINUS_DECOR_ALPHA (1 - DECOR_ALPHA) #define DECOR_GAMMA (1.5f) -VOID ixheaacd_mps_decor_init(ia_mps_decor_struct_handle, int, int); +IA_ERRORCODE ixheaacd_mps_decor_init(ia_mps_decor_struct_handle, int, int); VOID ixheaacd_mps_decor_apply( ia_mps_decor_struct_handle self, diff --git a/decoder/ixheaacd_mps_decorr.c b/decoder/ixheaacd_mps_decorr.c index 0d2622f..33b6aa5 100644 --- a/decoder/ixheaacd_mps_decorr.c +++ b/decoder/ixheaacd_mps_decorr.c @@ -23,7 +23,7 @@ #include <string.h> #include <assert.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" @@ -35,43 +35,51 @@ #include "ixheaacd_mps_decor.h" #include "ixheaacd_mps_hybfilter.h" - +#include "ixheaacd_error_standards.h" #include "ixheaacd_constants.h" -static WORD32 ixheaacd_decorr_delay[] = {11, 10, 5, 2}; - -static WORD32 ixheaacd_qmf_split_freq_0[] = {3, 15, 24, 65}; -static WORD32 ixheaacd_qmf_split_freq_1[] = {3, 50, 65, 65}; -static WORD32 ixheaacd_qmf_split_freq_2[] = {0, 15, 65, 65}; - -static FLOAT32 ixheaacd_lattice_coeff_0_filt_den_coeff[DECORR_FILT_0_ORD + 1] = - {1.000000f, -0.314818f, -0.256828f, -0.173641f, -0.115077f, 0.000599f, - 0.033343f, 0.122672f, -0.356362f, 0.128058f, 0.089800f}; -static FLOAT32 ixheaacd_lattice_coeff_0_filt_num_coeff[DECORR_FILT_0_ORD + 1] = - {0.089800f, 0.128058f, -0.356362f, 0.122672f, 0.033343f, 0.000599f, - -0.115077f, -0.173641f, -0.256828f, -0.314818f, 1.000000f}; - -static FLOAT32 ixheaacd_lattice_coeff_1_filt_den_coeff[DECORR_FILT_1_ORD + 1] = - {1.000000f, -0.287137f, -0.088940f, 0.123204f, -0.126111f, - 0.064218f, 0.045768f, -0.016264f, -0.122100f}; -static FLOAT32 ixheaacd_lattice_coeff_1_filt_num_coeff[DECORR_FILT_1_ORD + 1] = - {-0.122100f, -0.016264f, 0.045768f, 0.064218f, -0.126111f, - 0.123204f, -0.088940f, -0.287137f, 1.000000f}; - -static FLOAT32 ixheaacd_lattice_coeff_2_filt_den_coeff[DECORR_FILT_2_ORD + 1] = - {1.000000f, 0.129403f, -0.032633f, 0.035700f}; -static FLOAT32 ixheaacd_lattice_coeff_2_filt_num_coeff[DECORR_FILT_2_ORD + 1] = - {0.035700f, -0.032633f, 0.129403f, 1.000000f}; - -static FLOAT32 ixheaacd_lattice_coeff_3_filt_den_coeff[DECORR_FILT_3_ORD + 1] = - {1.000000f, 0.034742f, -0.013000f}; -static FLOAT32 ixheaacd_lattice_coeff_3_filt_num_coeff[DECORR_FILT_3_ORD + 1] = - {-0.013000f, 0.034742f, 1.000000f}; - -extern WORD32 +static const WORD32 ixheaacd_decorr_delay[] = {11, 10, 5, 2}; + +static const WORD32 ixheaacd_qmf_split_freq_0[] = {3, 15, 24, 65}; +static const WORD32 ixheaacd_qmf_split_freq_1[] = {3, 50, 65, 65}; +static const WORD32 ixheaacd_qmf_split_freq_2[] = {0, 15, 65, 65}; + +static const FLOAT32 + ixheaacd_lattice_coeff_0_filt_den_coeff[DECORR_FILT_0_ORD + 1] = { + 1.000000f, -0.314818f, -0.256828f, -0.173641f, -0.115077f, 0.000599f, + 0.033343f, 0.122672f, -0.356362f, 0.128058f, 0.089800f}; +static const FLOAT32 + ixheaacd_lattice_coeff_0_filt_num_coeff[DECORR_FILT_0_ORD + 1] = { + 0.089800f, 0.128058f, -0.356362f, 0.122672f, 0.033343f, 0.000599f, + -0.115077f, -0.173641f, -0.256828f, -0.314818f, 1.000000f}; + +static const FLOAT32 + ixheaacd_lattice_coeff_1_filt_den_coeff[DECORR_FILT_1_ORD + 1] = { + 1.000000f, -0.287137f, -0.088940f, 0.123204f, -0.126111f, + 0.064218f, 0.045768f, -0.016264f, -0.122100f}; +static const FLOAT32 + ixheaacd_lattice_coeff_1_filt_num_coeff[DECORR_FILT_1_ORD + 1] = { + -0.122100f, -0.016264f, 0.045768f, 0.064218f, -0.126111f, + 0.123204f, -0.088940f, -0.287137f, 1.000000f}; + +static const FLOAT32 + ixheaacd_lattice_coeff_2_filt_den_coeff[DECORR_FILT_2_ORD + 1] = { + 1.000000f, 0.129403f, -0.032633f, 0.035700f}; +static const FLOAT32 + ixheaacd_lattice_coeff_2_filt_num_coeff[DECORR_FILT_2_ORD + 1] = { + 0.035700f, -0.032633f, 0.129403f, 1.000000f}; + +static const FLOAT32 + ixheaacd_lattice_coeff_3_filt_den_coeff[DECORR_FILT_3_ORD + 1] = { + 1.000000f, 0.034742f, -0.013000f}; +static const FLOAT32 + ixheaacd_lattice_coeff_3_filt_num_coeff[DECORR_FILT_3_ORD + 1] = { + -0.013000f, 0.034742f, 1.000000f}; + +extern const WORD32 ixheaacd_hybrid_band_71_to_processing_band_28_map[MAX_HYBRID_BANDS_MPS]; -static WORD32 ixheaacd_hybrid_to_qmf_map[MAX_HYBRID_BANDS_MPS] = { +static const WORD32 ixheaacd_hybrid_to_qmf_map[MAX_HYBRID_BANDS_MPS] = { 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, @@ -185,10 +193,10 @@ static VOID ixheaacd_mps_decor_energy_adjustment( } } -void ixheaacd_mps_decor_init(ia_mps_decor_struct_handle self, WORD32 subbands, - WORD32 decor_config) { +IA_ERRORCODE ixheaacd_mps_decor_init(ia_mps_decor_struct_handle self, + WORD32 subbands, WORD32 decor_config) { WORD32 i, reverb_band; - WORD32 *splitfreq; + const WORD32 *splitfreq; switch (decor_config) { case 0: @@ -201,7 +209,7 @@ void ixheaacd_mps_decor_init(ia_mps_decor_struct_handle self, WORD32 subbands, splitfreq = ixheaacd_qmf_split_freq_2; break; default: - return; + return IA_FATAL_ERROR; } self->num_bins = subbands; @@ -218,7 +226,7 @@ void ixheaacd_mps_decor_init(ia_mps_decor_struct_handle self, WORD32 subbands, self->decor_nrg_smooth.num_bins = self->num_bins; - return; + return IA_NO_ERROR; } VOID ixheaacd_mps_decor_apply( diff --git a/decoder/ixheaacd_mps_hybrid_filt.c b/decoder/ixheaacd_mps_hybrid_filt.c index be53625..044f4b1 100644 --- a/decoder/ixheaacd_mps_hybrid_filt.c +++ b/decoder/ixheaacd_mps_hybrid_filt.c @@ -19,7 +19,7 @@ */ #include <math.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" @@ -28,14 +28,16 @@ #include "ixheaacd_mps_interface.h" #include "ixheaacd_mps_polyphase.h" +#include "ixheaacd_constants.h" +#include "ixheaacd_basic_ops32.h" #include "ixheaacd_mps_hybfilter.h" -extern WORD32 ixheaacd_ia_mps_hyb_filter_coeff_8[QMF_HYBRID_FILT_ORDER]; -extern WORD32 ixheaacd_mps_hyb_filter_coeff_2[QMF_HYBRID_FILT_ORDER]; -extern WORD32 ixheaacd_cosine[8][13]; -extern WORD32 ixheaacd_sine[8][13]; -extern WORD32 ixheaacd_cosine2[2][13]; +extern const WORD32 ixheaacd_ia_mps_hyb_filter_coeff_8[QMF_HYBRID_FILT_ORDER]; +extern const WORD32 ixheaacd_mps_hyb_filter_coeff_2[QMF_HYBRID_FILT_ORDER]; +extern const WORD32 ixheaacd_cosine[8][13]; +extern const WORD32 ixheaacd_sine[8][13]; +extern const WORD32 ixheaacd_cosine2[2][13]; static WORD32 ixheaacd_mps_mult32_local(WORD32 a, WORD32 b, WORD16 shift) { WORD64 temp; @@ -47,7 +49,7 @@ static WORD32 ixheaacd_mps_mult32_local(WORD32 a, WORD32 b, WORD16 shift) { static VOID ixheaacd_mps_hyb_filt_type1( ia_cmplx_w32_struct *input, ia_cmplx_w32_struct output[8][MAX_TIME_SLOTS], - WORD32 num_samples, WORD32 *filt_coeff) + WORD32 num_samples, const WORD32 *filt_coeff) { WORD32 i, n, q; @@ -71,13 +73,14 @@ static VOID ixheaacd_mps_hyb_filt_type1( in_re = (WORD32)(input[n + i].re); in_im = (WORD32)(input[n + i].im); - in_re = in_re << shift; - in_im = in_im << shift; + in_re = ixheaacd_shl32_sat(in_re, shift); + in_im = ixheaacd_shl32_sat(in_im, shift); coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n]; - temp = ixheaacd_mps_mult32_local(in_re, modulation_fac_re, 30) - - ixheaacd_mps_mult32_local(in_im, modulation_fac_im, 30); + temp = ixheaacd_sub32_sat( + ixheaacd_mps_mult32_local(in_re, modulation_fac_re, 30), + ixheaacd_mps_mult32_local(in_im, modulation_fac_im, 30)); if (temp >= 1073741823) temp = 1073741823; @@ -87,8 +90,9 @@ static VOID ixheaacd_mps_hyb_filt_type1( temp = ixheaacd_mps_mult32_local(coeff, temp, 30); acc_re = acc_re + (WORD64)temp; - temp = ixheaacd_mps_mult32_local(in_im, modulation_fac_re, 30) + - ixheaacd_mps_mult32_local(in_re, modulation_fac_im, 30); + temp = ixheaacd_add32_sat( + ixheaacd_mps_mult32_local(in_im, modulation_fac_re, 30), + ixheaacd_mps_mult32_local(in_re, modulation_fac_im, 30)); if (temp >= 1073741823) temp = 1073741823; @@ -107,7 +111,7 @@ static VOID ixheaacd_mps_hyb_filt_type1( static VOID ixheaacd_mps_hyb_filt_type2( ia_cmplx_w32_struct *input, ia_cmplx_w32_struct output[2][MAX_TIME_SLOTS], - WORD32 num_samples, WORD32 *filt_coeff) + WORD32 num_samples, const WORD32 *filt_coeff) { WORD32 i, n, q; @@ -130,8 +134,8 @@ static VOID ixheaacd_mps_hyb_filt_type2( in_re = (WORD32)(input[n + i].re); in_im = (WORD32)(input[n + i].im); - in_re = in_re << shift; - in_im = in_im << shift; + in_re = ixheaacd_shl32_sat(in_re, shift); + in_im = ixheaacd_shl32_sat(in_im, shift); coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n]; diff --git a/decoder/ixheaacd_mps_parse.c b/decoder/ixheaacd_mps_parse.c index 7f45d3f..1d47890 100644 --- a/decoder/ixheaacd_mps_parse.c +++ b/decoder/ixheaacd_mps_parse.c @@ -18,7 +18,9 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include <math.h> -#include <ixheaacd_type_def.h> +#include <assert.h> +#include <stdio.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" @@ -29,86 +31,85 @@ #include "ixheaacd_mps_nlc_dec.h" #include "ixheaacd_mps_hybfilter.h" -#include <assert.h> -#include <stdio.h> - #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) -static int ixheaacd_freq_res_table[] = {0, 28, 20, 14, 10, 7, 5, 4}; +static const int ixheaacd_freq_res_table[] = {0, 28, 20, 14, 10, 7, 5, 4}; -static int +static const int ixheaacd_hybrid_band_71_to_processing_band_4_map[MAX_HYBRID_BANDS_MPS] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3}; -static int +static const int ixheaacd_hybrid_band_71_to_processing_band_5_map[MAX_HYBRID_BANDS_MPS] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4}; -static int +static const int ixheaacd_hybrid_band_71_to_processing_band_7_map[MAX_HYBRID_BANDS_MPS] = { 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6}; -static int +static const int ixheaacd_hybrid_band_71_to_processing_band_10_map[MAX_HYBRID_BANDS_MPS] = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}; -static int +static const int ixheaacd_hybrid_band_71_to_processing_band_14_map[MAX_HYBRID_BANDS_MPS] = { 0, 0, 0, 0, 1, 1, 2, 3, 4, 4, 5, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13}; -int ixheaacd_hybrid_band_71_to_processing_band_20_map[MAX_HYBRID_BANDS_MPS] = { - 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, - 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, - 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, - 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19}; +const int + ixheaacd_hybrid_band_71_to_processing_band_20_map[MAX_HYBRID_BANDS_MPS] = { + 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, + 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, + 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19}; -int ixheaacd_hybrid_band_71_to_processing_band_28_map[MAX_HYBRID_BANDS_MPS] = { - 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, - 23, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, - 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27}; +const int + ixheaacd_hybrid_band_71_to_processing_band_28_map[MAX_HYBRID_BANDS_MPS] = { + 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, + 23, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, + 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27}; -static float ixheaacd_mps_clip_gain_table[] = {1.000000f, 1.189207f, 1.414213f, - 1.681792f, 2.000000f, 2.378414f, - 2.828427f, 4.000000f}; +static const float ixheaacd_mps_clip_gain_table[] = { + 1.000000f, 1.189207f, 1.414213f, 1.681792f, + 2.000000f, 2.378414f, 2.828427f, 4.000000f}; -static int ixheaacd_mps_stride_table[] = {1, 2, 5, 28}; +static const int ixheaacd_mps_stride_table[] = {1, 2, 5, 28}; -static float ixheaacd_cld_de_quant_table[] = { +static const float ixheaacd_cld_de_quant_table[] = { -150.0, -45.0, -40.0, -35.0, -30.0, -25.0, -22.0, -19.0, -16.0, -13.0, -10.0, -8.0, -6.0, -4.0, -2.0, 0.0, 2.0, 4.0, 6.0, 8.0, 10.0, 13.0, 16.0, 19.0, 22.0, 25.0, 30.0, 35.0, 40.0, 45.0, 150.0}; -static float ixheaacd_icc_de_quant_table[] = { +static const float ixheaacd_icc_de_quant_table[] = { 1.0000f, 0.9370f, 0.84118f, 0.60092f, 0.36764f, 0.0f, -0.5890f, -0.9900f}; -float ixheaacd_ipd_de_quant_table[] = { +const float ixheaacd_ipd_de_quant_table[] = { 0.f, 0.392699082f, 0.785398163f, 1.178097245f, 1.570796327f, 1.963495408f, 2.35619449f, 2.748893572f, 3.141592654f, 3.534291735f, 3.926990817f, 4.319689899f, 4.71238898f, 5.105088062f, 5.497787144f, 5.890486225f}; -int ixheaacd_ipd_de_quant_table_q28[] = { +const int ixheaacd_ipd_de_quant_table_q28[] = { 0, 105414360, 210828720, 316243072, 421657440, 527071776, 632486144, 737900480, 843314880, 948729216, 1054143552, 1159557888, 1264972288, 1370386688, 1475800960, 1581215360}; -static int ixheaacd_smoothing_time_table[] = {64, 128, 256, 512}; +static const int ixheaacd_smoothing_time_table[] = {64, 128, 256, 512}; -static int ixheaacd_inverse_smoothing_time_table_q30[] = {16777216, 8388608, - 4194304, 2097152}; +static const int ixheaacd_inverse_smoothing_time_table_q30[] = { + 16777216, 8388608, 4194304, 2097152}; static WORD32 bound_check(WORD32 var, WORD32 lower_bound, WORD32 upper_bound) { var = min(var, upper_bound); @@ -499,12 +500,12 @@ VOID ixheaacd_mps_frame_parsing(ia_mps_dec_state_struct *self, UWORD64 c_64; unsigned short b; unsigned short r[1]; - unsigned short table_64[] = {6, 11, 16, 20, 23, 27, 30, 33, 35, 38, 40, - 42, 44, 46, 48, 49, 51, 52, 53, 55, 56, 57, - 58, 58, 59, 60, 60, 60, 61, 61, 61, 61}; - unsigned short table_32[] = {5, 9, 13, 16, 18, 20, 22, 24, - 25, 26, 27, 28, 29, 29, 30, 30}; - unsigned short *tab = NULL; + static const unsigned short table_64[] = { + 6, 11, 16, 20, 23, 27, 30, 33, 35, 38, 40, 42, 44, 46, 48, 49, + 51, 52, 53, 55, 56, 57, 58, 58, 59, 60, 60, 60, 61, 61, 61, 61}; + static const unsigned short table_32[] = {5, 9, 13, 16, 18, 20, 22, 24, + 25, 26, 27, 28, 29, 29, 30, 30}; + unsigned const short *tab = NULL; int k; unsigned short h; WORD32 nbits_tr_slots = 0; @@ -1085,4 +1086,4 @@ WORD32 ixheaacd_mps_header_decode(ia_mps_dec_state_struct *self) { self->bs_high_rate_mode = self->config->bs_high_rate_mode; return 0; -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_mps_poly_filt.c b/decoder/ixheaacd_mps_poly_filt.c index 1d5ea47..315f0c7 100644 --- a/decoder/ixheaacd_mps_poly_filt.c +++ b/decoder/ixheaacd_mps_poly_filt.c @@ -21,24 +21,23 @@ #include <stdio.h> #include <string.h> #include <math.h> -#include <ixheaacd_type_def.h> -#include <ixheaacd_interface.h> +#include "ixheaacd_type_def.h" +#include "ixheaacd_interface.h" #include "ixheaacd_mps_polyphase.h" -#include <ixheaacd_type_def.h> #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" #include "ixheaacd_mps_dec.h" #include "ixheaacd_mps_interface.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> +#include "ixheaacd_basic_ops32.h" #include "ixheaacd_function_selector.h" extern const WORD32 ixheaacd_mps_polyphase_filter_coeff_fix[10 * MAX_NUM_QMF_BANDS_SAC / 2]; -extern WORD32 ixheaacd_mps_pre_re[64]; -extern WORD32 ixheaacd_mps_pre_im[64]; -extern WORD32 ixheaacd_mps_post_re[128]; -extern WORD32 ixheaacd_mps_post_im[128]; +extern const WORD32 ixheaacd_mps_pre_re[64]; +extern const WORD32 ixheaacd_mps_pre_im[64]; +extern const WORD32 ixheaacd_mps_post_re[128]; +extern const WORD32 ixheaacd_mps_post_im[128]; static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) { WORD32 result; @@ -67,8 +66,9 @@ static VOID ixheaacd_float_to_int32(FLOAT32 *in, WORD32 *out, WORD32 q_factor, for (loop = 0; loop < sample; loop++) out[loop] = (WORD32)(in[loop] * temp); } -VOID ixheaacd_mps_synt_pre_twiddle_dec(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, WORD32 resolution) { +VOID ixheaacd_mps_synt_pre_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 resolution) { WORD32 tmp, k; for (k = 0; k < 2 * resolution; k += 2) { tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_in[k], table_re[k >> 1]), @@ -81,24 +81,27 @@ VOID ixheaacd_mps_synt_pre_twiddle_dec(WORD32 *ptr_in, WORD32 *table_re, } } -VOID ixheaacd_mps_synt_post_twiddle_dec(WORD32 *ptr_in, WORD32 *table_re, - WORD32 *table_im, WORD32 resolution) { +VOID ixheaacd_mps_synt_post_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 resolution) { WORD32 tmp, k; for (k = 0; k < 2 * resolution; k += 2) { tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_in[k], table_re[k]), ixheaacd_mult32(ptr_in[k + 1], table_im[k])); - ptr_in[k + 1] = - ixheaacd_add32_sat(ixheaacd_mult32(-ptr_in[k], table_im[k]), - ixheaacd_mult32(ptr_in[k + 1], table_re[k])); + ptr_in[k + 1] = ixheaacd_add32_sat( + ixheaacd_mult32(ixheaacd_negate32_sat(ptr_in[k]), table_im[k]), + ixheaacd_mult32(ptr_in[k + 1], table_re[k])); ptr_in[k] = tmp; } } VOID ixheaacd_mps_synt_post_fft_twiddle_dec(WORD32 resolution, WORD32 *fin_re, - WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state) { + WORD32 *fin_im, + const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state) { WORD32 l; for (l = 0; l < 2 * resolution; l++) { state[2 * resolution - l - 1] = diff --git a/decoder/ixheaacd_mps_pre_mix.c b/decoder/ixheaacd_mps_pre_mix.c index 36426cf..c490e78 100644 --- a/decoder/ixheaacd_mps_pre_mix.c +++ b/decoder/ixheaacd_mps_pre_mix.c @@ -17,7 +17,11 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include <math.h> +#include <memory.h> + +#include <assert.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" #include "ixheaacd_mps_polyphase.h" @@ -25,15 +29,9 @@ #include "ixheaacd_mps_dec.h" #include "ixheaacd_mps_interface.h" -#include <ixheaacd_type_def.h> #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> - -#include <math.h> -#include <memory.h> - -#include <assert.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #undef ABS_THR #define ABS_THR 1.0e-9f @@ -58,13 +56,11 @@ extern const WORD32 ixheaacd_c_l_table_Q31[31]; extern const WORD32 ixheaacd_sin_table_Q31[8][31]; extern const WORD32 ixheaacd_cos_table_Q31[8][31]; extern const WORD32 ixheaacd_atan_table_Q28[16][8][31]; -extern WORD32 ixheaacd_ipd_de_quant_table_q28[16]; +extern const WORD32 ixheaacd_ipd_de_quant_table_q28[16]; #define P_PI 3.1415926535897932 #define PI_IN_Q28 843314880 -extern WORD32 ixheaacd_ipd_de_quant_table_q28[16]; - #define P_PI 3.1415926535897932 #define PI_IN_Q28 843314880 diff --git a/decoder/ixheaacd_mps_rom.c b/decoder/ixheaacd_mps_rom.c index 858f7f3..6dd2ded 100644 --- a/decoder/ixheaacd_mps_rom.c +++ b/decoder/ixheaacd_mps_rom.c @@ -23,7 +23,7 @@ #include <string.h> #include <assert.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" @@ -34,7 +34,7 @@ #include "ixheaacd_mps_nlc_dec.h" #include "ixheaacd_mps_huff_tab.h" -ia_huff_cld_nodes_struct ixheaacd_huff_cld_nodes = { +const ia_huff_cld_nodes_struct ixheaacd_huff_cld_nodes = { {{{{-1, 1}, {-2, 2}, {-3, 3}, {-4, 4}, {-5, 5}, {-6, 6}, {-7, 7}, {-8, 8}, {-9, 9}, {-10, 10}, {-11, 11}, {-12, 12}, {-13, 13}, {15, 14}, {-14, 16}, {-15, 17}, {-16, 18}, {-17, 19}, @@ -375,7 +375,7 @@ ia_huff_cld_nodes_struct ixheaacd_huff_cld_nodes = { {-23, 93}, {-7, 94}, {-147, -148}, {-116, -131}, {-25, 95}, {-40, 0}, {0, 0}, {0, 0}, {0, 0}}}}}}; -ia_huff_icc_nodes_struct ixheaacd_huff_icc_nodes = { +const ia_huff_icc_nodes_struct ixheaacd_huff_icc_nodes = { {{{{-1, 1}, {-2, 2}, {-3, 3}, {-4, 4}, {-5, 5}, {-6, 6}, {-7, -8}}}, {{{-1, 1}, {-2, 2}, {-3, 3}, {-4, 4}, {-5, 5}, {-6, 6}, {-7, -8}}}, {{{-1, 1}, {-2, 2}, {-3, 3}, {-4, 4}, {-5, 5}, {-6, 6}, {-7, -8}}}}, @@ -586,7 +586,7 @@ ia_huff_icc_nodes_struct ixheaacd_huff_icc_nodes = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}}}}}; -ia_huff_ipd_nodes_struct ixheaacd_huff_ipd_nodes = { +const ia_huff_ipd_nodes_struct ixheaacd_huff_ipd_nodes = { {{{-1, 1}, {-8, 2}, {-2, 3}, {5, 4}, {-7, 6}, {-3, -5}, {-4, -6}}}, {{{{-1, 1}, {-8, 2}, {-2, 3}, {5, 4}, {-3, -7}, {-6, 6}, {-4, -5}}}, {{{-1, 1}, {-2, 2}, {-8, 3}, {-3, 4}, {-7, 5}, {-4, 6}, {-5, -6}}}, @@ -790,7 +790,7 @@ ia_huff_ipd_nodes_struct ixheaacd_huff_ipd_nodes = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}}}}}; -ia_huff_pt0_nodes_struct ixheaacd_huff_part0_nodes = { +const ia_huff_pt0_nodes_struct ixheaacd_huff_part0_nodes = { {{2, 1}, {4, 3}, {6, 5}, {8, 7}, {10, 9}, {12, 11}, {14, 13}, {-8, 15}, {-9, 16}, {-10, 17}, {-18, 18}, {-17, -19}, {-16, 19}, {-11, -20}, {-15, -21}, {-7, 20}, {-22, 21}, {-12, -14}, @@ -803,7 +803,7 @@ ia_huff_pt0_nodes_struct ixheaacd_huff_part0_nodes = { {-5, 18}, {-4, -19}, {-3, 19}, {-1, 20}, {-2, -20}, {22, 21}, {-21, 23}, {-22, -26}, {-23, 24}, {-24, -25}}}; -ia_huff_pt0_nodes_struct ixheaacd_huff_pilot_nodes = { +const ia_huff_pt0_nodes_struct ixheaacd_huff_pilot_nodes = { {{2, 1}, {4, 3}, {6, 5}, {8, 7}, {10, 9}, {12, 11}, {14, 13}, {-8, 15}, {-9, 16}, {-10, 17}, {-18, 18}, {-17, -19}, {-16, 19}, {-11, -20}, {-15, -21}, {-7, 20}, {-22, 21}, {-12, -14}, @@ -816,10 +816,10 @@ ia_huff_pt0_nodes_struct ixheaacd_huff_pilot_nodes = { {-5, 18}, {-4, -19}, {-3, 19}, {-1, 20}, {-2, -20}, {22, 21}, {-21, 23}, {-22, -26}, {-23, 24}, {-24, -25}}}; -ia_huff_lav_nodes_struct ixheaacd_huff_lav_idx_nodes = { +const ia_huff_lav_nodes_struct ixheaacd_huff_lav_idx_nodes = { {{-1, 1}, {-2, 2}, {-3, -4}}}; -ia_huff_res_nodes_struct ixheaacd_huff_reshape_nodes = { +const ia_huff_res_nodes_struct ixheaacd_huff_reshape_nodes = { {{2, 1}, {4, 3}, {6, 5}, {-33, 7}, {-17, 8}, {-49, 9}, {-34, 10}, {12, 11}, {-18, -35}, {-50, 13}, {15, 14}, {-40, 16}, {-36, 17}, {-19, 18}, {-1, -37}, {-51, 19}, {21, 20}, {-38, -65}, @@ -4762,7 +4762,7 @@ const WORD32 0x0070c8a4, 0xffeff6cb, 0x006b47fa, 0xfff0065d, 0x0065fde5, 0xffefc9b9, 0x006090c3, 0xffed978a, 0x005b5370, 0xffede50e}; -WORD32 ixheaacd_mps_pre_re[64] = { +const WORD32 ixheaacd_mps_pre_re[64] = { 0x01fff621, 0x01ffa72e, 0x01ff0956, 0x01fe1caf, 0x01fce15f, 0x01fb5797, 0x01f97f92, 0x01f7599a, 0x01f4e603, 0x01f2252f, 0x01ef178a, 0x01ebbd8c, 0x01e817ba, 0x01e426a4, 0x01dfeae6, 0x01db6526, 0x01d69617, 0x01d17e77, @@ -4775,7 +4775,7 @@ WORD32 ixheaacd_mps_pre_re[64] = { 0x00764d3e, 0x006a0a7f, 0x005db766, 0x005155d9, 0x0044e7c1, 0x00386f0a, 0x002bed9e, 0x001f656d, 0x0012d864, 0x00064873}; -WORD32 ixheaacd_mps_pre_im[64] = { +const WORD32 ixheaacd_mps_pre_im[64] = { 0x00064874, 0x0012d865, 0x001f656e, 0x002beda0, 0x00386f0b, 0x0044e7c3, 0x005155da, 0x005db767, 0x006a0a80, 0x00764d3f, 0x00827dc0, 0x008e9a22, 0x009aa086, 0x00a68f12, 0x00b263ef, 0x00be1d49, 0x00c9b953, 0x00d53641, @@ -4788,7 +4788,7 @@ WORD32 ixheaacd_mps_pre_im[64] = { 0x01f2252f, 0x01f4e603, 0x01f7599a, 0x01f97f92, 0x01fb5797, 0x01fce15f, 0x01fe1caf, 0x01ff0956, 0x01ffa72f, 0x01fff621}; -WORD32 ixheaacd_mps_post_re[128] = { +const WORD32 ixheaacd_mps_post_re[128] = { 0x7fffffff, 0x7ff62182, 0x7fd8878d, 0x7fa736b3, 0x7f62368e, 0x7f0991c2, 0x7e9d55fa, 0x7e1d93e8, 0x7d8a5f3d, 0x7ce3ceae, 0x7c29fbea, 0x7b5d0399, 0x7a7d0555, 0x798a23ab, 0x7884840c, 0x776c4ed3, 0x7641af33, 0x7504d33b, @@ -4812,7 +4812,7 @@ WORD32 ixheaacd_mps_post_re[128] = { 0x8275a09e, 0x81e26bf8, 0x8162a9ea, 0x80f66e27, 0x809dc95f, 0x8058c93f, 0x8027786a, 0x8009de7a}; -WORD32 ixheaacd_mps_post_im[128] = { +const WORD32 ixheaacd_mps_post_im[128] = { 0x00000000, 0x03242ac0, 0x0647d97f, 0x096a904d, 0x0c8bd363, 0x0fab2732, 0x12c81077, 0x15e2144e, 0x18f8b847, 0x1c0b8277, 0x1f19f989, 0x2223a4d4, 0x25280c6e, 0x2826b93a, 0x2b1f34fe, 0x2e110a76, 0x30fbc563, 0x33def29e, @@ -4836,15 +4836,15 @@ WORD32 ixheaacd_mps_post_im[128] = { 0x18f8b78f, 0x15e21395, 0x12c80fbd, 0x0fab2678, 0x0c8bd2a9, 0x096a8f92, 0x0647d8c3, 0x03242a04}; -WORD32 ixheaacd_ia_mps_hyb_filter_coeff_8[QMF_HYBRID_FILT_ORDER] = { +const WORD32 ixheaacd_ia_mps_hyb_filter_coeff_8[QMF_HYBRID_FILT_ORDER] = { 8011005, 24378459, 48821601, 78019304, 106140545, 126634002, 134217728, 126634002, 106140545, 78019304, 48821601, 24378459, 8011805}; -WORD32 ixheaacd_mps_hyb_filter_coeff_2[QMF_HYBRID_FILT_ORDER] = { +const WORD32 ixheaacd_mps_hyb_filter_coeff_2[QMF_HYBRID_FILT_ORDER] = { 0, 20395592, 0, -78309485, 0, 328528819, 536870911, 328528819, 0, -78309485, 0, 20395592, 0}; -WORD32 ixheaacd_cosine[8][13] = { +const WORD32 ixheaacd_cosine[8][13] = { { -759250175, -410903263, -46, 410903167, 759250111, 992008063, 1073741823, 992008063, 759250111, 410903167, -46, -410903263, @@ -4883,7 +4883,7 @@ WORD32 ixheaacd_cosine[8][13] = { {-759249407, -410902399, 704, 410903679, 759250367, 992008191, 1073741823, 992008191, 759250367, 410903679, 704, -410902399, -759249407}}; -WORD32 ixheaacd_sine[8][13] = { +const WORD32 ixheaacd_sine[8][13] = { { 759250047, 992008063, 1073741823, 992008127, 759250111, 410903231, 0, -410903231, -759250111, -992008127, -1073741823, -992008063, -759250047, @@ -4915,7 +4915,7 @@ WORD32 ixheaacd_sine[8][13] = { {-759250879, -992008447, -1073741823, -992007871, -759249855, -410903039, 0, 410903039, 759249855, 992007871, 1073741823, 992008447, 759250879}}; -WORD32 ixheaacd_cosine2[2][13] = { +const WORD32 ixheaacd_cosine2[2][13] = { { 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, 1073741823, diff --git a/decoder/ixheaacd_mps_smoothing.c b/decoder/ixheaacd_mps_smoothing.c index 9a46d5c..f4917a4 100644 --- a/decoder/ixheaacd_mps_smoothing.c +++ b/decoder/ixheaacd_mps_smoothing.c @@ -17,18 +17,17 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include <math.h> +#include <stdlib.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" #include "ixheaacd_mps_polyphase.h" #include "ixheaacd_mps_dec.h" #include "ixheaacd_mps_interface.h" -#include <math.h> -#include <stdlib.h> -#include <ixheaacd_type_def.h> #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" VOID ixheaacd_mps_pre_matrix_mix_matrix_smoothing( ia_mps_dec_state_struct *self) { diff --git a/decoder/ixheaacd_mps_temp_process.c b/decoder/ixheaacd_mps_temp_process.c index 43e5781..736996c 100644 --- a/decoder/ixheaacd_mps_temp_process.c +++ b/decoder/ixheaacd_mps_temp_process.c @@ -17,7 +17,13 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include <math.h> +#include <float.h> +#include <memory.h> + +#include <assert.h> + +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" #include "ixheaacd_mps_polyphase.h" @@ -26,25 +32,19 @@ #include "ixheaacd_mps_process.h" -#include <math.h> -#include <float.h> -#include <memory.h> - -#include <assert.h> - #include "ixheaacd_common_rom.h" #include "ixheaacd_defines.h" #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.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_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" @@ -67,13 +67,13 @@ #define max(a, b) ((a > b) ? (a) : (b)) #define min(a, b) ((a < b) ? (a) : (b)) -static FLOAT32 ixheaacd_bp[BP_SIZE] = { +static const FLOAT32 ixheaacd_bp[BP_SIZE] = { 0.0000f, 0.0005f, 0.0092f, 0.0587f, 0.2580f, 0.7392f, 0.9791f, 0.9993f, 1.0000f, 1.0000f, 1.0000f, 1.0000f, 0.9999f, 0.9984f, 0.9908f, 0.9639f, 0.8952f, 0.7711f, 0.6127f, 0.4609f, 0.3391f, 0.2493f, 0.1848f, 0.1387f, 0.1053f}; -static FLOAT32 ixheaacd_gf[BP_SIZE] = { +static const FLOAT32 ixheaacd_gf[BP_SIZE] = { 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 1e-008f, 8.1e-007f, 3.61e-006f, 8.41e-006f, 1.6e-005f, 2.704e-005f, 3.969e-005f, 5.625e-005f, 7.396e-005f, @@ -241,4 +241,4 @@ WORD32 ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) { ixheaacd_mps_synt_calc(self); return err; -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_mps_temp_reshape.c b/decoder/ixheaacd_mps_temp_reshape.c index 428fabd..fd8e62c 100644 --- a/decoder/ixheaacd_mps_temp_reshape.c +++ b/decoder/ixheaacd_mps_temp_reshape.c @@ -17,7 +17,8 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include <math.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_config.h" @@ -25,7 +26,6 @@ #include "ixheaacd_mps_dec.h" #include "ixheaacd_mps_interface.h" -#include <math.h> #define max(a, b) ((a) > (b) ? (a) : (b)) @@ -38,7 +38,7 @@ #define GES_ALPHA (0.99637864f) #define GES_BETA (0.9643691f) -extern WORD32 +extern const WORD32 ixheaacd_hybrid_band_71_to_processing_band_20_map[MAX_HYBRID_BANDS_MPS]; VOID ixheaacd_mps_env_init(ia_mps_dec_state_struct *self) { @@ -191,4 +191,4 @@ VOID ixheaacd_mps_time_env_shaping(ia_mps_dec_state_struct *self) { } } } -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_multichannel.c b/decoder/ixheaacd_multichannel.c index ae20586..d914ad2 100644 --- a/decoder/ixheaacd_multichannel.c +++ b/decoder/ixheaacd_multichannel.c @@ -19,7 +19,7 @@ */ #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_sbr_common.h" #include "ixheaacd_constants.h" @@ -74,7 +74,7 @@ #include "ixheaacd_headerdecode.h" #include "ixheaacd_multichannel.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" WORD cblock_decode_huff_symbol(UWORD8 *ptr_read_next, WORD32 bit_pos, const UWORD16 *huff_ori, WORD16 *input, diff --git a/decoder/ixheaacd_pns_js_thumb.c b/decoder/ixheaacd_pns_js_thumb.c index 534ec5b..39985dc 100644 --- a/decoder/ixheaacd_pns_js_thumb.c +++ b/decoder/ixheaacd_pns_js_thumb.c @@ -17,24 +17,26 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ +#include <string.h> +#include <stdio.h> +#include <stdlib.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_basic_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_error_codes.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" #include "ixheaacd_aac_imdct.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_pulsedata.h" @@ -57,10 +59,6 @@ #include "ixheaacd_tns.h" #include "ixheaacd_function_selector.h" -#include <string.h> -#include <stdio.h> -#include <stdlib.h> - static PLATFORM_INLINE WORD16 ixheaacd_is_correlation( ia_aac_dec_channel_info_struct *ptr_aac_dec_channel_info, WORD16 pns_band) { ia_pns_correlation_info_struct *ptr_corr_info = @@ -440,4 +438,4 @@ VOID ixheaacd_aac_tns_process( } } } -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_pred_vec_block.c b/decoder/ixheaacd_pred_vec_block.c index 7831d07..11ea410 100644 --- a/decoder/ixheaacd_pred_vec_block.c +++ b/decoder/ixheaacd_pred_vec_block.c @@ -21,7 +21,7 @@ #include <stdlib.h> #include <math.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_sbr_const.h" #include "ixheaacd_pvc_dec.h" diff --git a/decoder/ixheaacd_process.c b/decoder/ixheaacd_process.c index d9e7175..1aae894 100644 --- a/decoder/ixheaacd_process.c +++ b/decoder/ixheaacd_process.c @@ -21,15 +21,14 @@ #include <string.h> #include <math.h> -#include <ixheaacd_type_def.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_memory_standards.h" #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_env_extr_part.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_common_rom.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_pns.h" @@ -110,6 +109,7 @@ IA_ERRORCODE ixheaacd_esbr_process(ia_usac_data_struct *usac_data, WORD32 stereo_config_idx, WORD16 num_channels, WORD32 audio_object_type) { + WORD32 ch; WORD32 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; @@ -128,6 +128,13 @@ IA_ERRORCODE ixheaacd_esbr_process(ia_usac_data_struct *usac_data, self->sbr_mode = usac_data->sbr_mode; self->aot_usac_flag = usac_data->usac_flag; + for (ch = 0; ch < num_channels; ch++) { + if ((self->pstr_sbr_channel[ch] + ->str_sbr_dec.str_synthesis_qmf_bank.qmf_filter_state_size) < + QMF_FILTER_STATE_SYN_SIZE) + return IA_FATAL_ERROR; + } + err_code = ixheaacd_applysbr(self, esbr_bit_str, NULL, &num_channels, 1, 0, 0, &sbr_scratch_struct, 0, 1, 0, it_bit_buff, NULL, 0, audio_object_type); @@ -173,7 +180,7 @@ static WORD32 ixheaacd_read_ext_element( UWORD32 usac_ext_element_present; UWORD32 usac_ext_element_use_dft_length; UWORD32 pay_load_length, tmp; - UWORD32 i; + WORD32 i; usac_ext_element_present = ixheaacd_read_bits_buf(it_bit_buff, 1); if (usac_ext_element_present) { @@ -197,12 +204,22 @@ static WORD32 ixheaacd_read_ext_element( tmp = ixheaacd_read_bits_buf(it_bit_buff, 2); if (pstr_usac_dec_config->usac_ext_ele_payload_present[elem_idx]) { - for (i = 0; i < pay_load_length; i++) { - pstr_usac_dec_config->usac_ext_gain_payload_buf - [i + pstr_usac_dec_config->usac_ext_gain_payload_len] = + WORD32 preroll_counter = pstr_usac_dec_config->preroll_counter; + int payload_buffer_offeset = 0; + for (i = 0; i < preroll_counter; i++) + payload_buffer_offeset += + pstr_usac_dec_config->usac_ext_gain_payload_len[i] * + sizeof(WORD8); + if ((pay_load_length + payload_buffer_offeset) > + (MAX_AUDIO_PREROLLS * 768)) + return IA_FATAL_ERROR; + for (i = 0; i < ((WORD32)pay_load_length); i++) { + pstr_usac_dec_config + ->usac_ext_gain_payload_buf[i + payload_buffer_offeset] = ixheaacd_read_bits_buf(it_bit_buff, 8); } - pstr_usac_dec_config->usac_ext_gain_payload_len += pay_load_length; + pstr_usac_dec_config->usac_ext_gain_payload_len[preroll_counter] += + pay_load_length; } else { if (it_bit_buff->cnt_bits < (WORD32)(pay_load_length << 3)) { longjmp(*(it_bit_buff->xaac_jmp_buf), @@ -295,7 +312,6 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, WORD32 num_ch_out = 0; WORD32 num_elements = pstr_usac_dec_config->num_elements; - pstr_usac_dec_config->usac_ext_gain_payload_len = 0; pstr_usac_data->usac_independency_flg = ixheaacd_read_bits_buf(it_bit_buff, 1); @@ -354,7 +370,7 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data, if (err_code < 0) return err_code; } - if (stereo_config_index > 0) { + if (stereo_config_index > 0 && pstr_usac_data->sbr_ratio_idx > 0) { FLOAT32 **ptr_inp[2 * 2]; WORD32 ch; diff --git a/decoder/ixheaacd_ps_bitdec.c b/decoder/ixheaacd_ps_bitdec.c index 73ac4e0..d255f48 100644 --- a/decoder/ixheaacd_ps_bitdec.c +++ b/decoder/ixheaacd_ps_bitdec.c @@ -17,24 +17,24 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include "string.h" +#include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.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_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -275,4 +275,4 @@ VOID ixheaacd_decode_ps_data(ia_ps_dec_struct *ptr_ps_dec) { if (ptr_ps_dec->icc_mode == 2) ixheaacd_map_34_params_to_20(ptr_ps_dec->icc_par_table[e]); } -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_ps_dec.c b/decoder/ixheaacd_ps_dec.c index f8cd6ec..f576ca8 100644 --- a/decoder/ixheaacd_ps_dec.c +++ b/decoder/ixheaacd_ps_dec.c @@ -19,17 +19,17 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops_arr.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" @@ -39,7 +39,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -51,7 +51,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" diff --git a/decoder/ixheaacd_pvc_rom.c b/decoder/ixheaacd_pvc_rom.c index 3cf4ad5..f590ee5 100644 --- a/decoder/ixheaacd_pvc_rom.c +++ b/decoder/ixheaacd_pvc_rom.c @@ -17,7 +17,7 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_sbr_const.h" #include "ixheaacd_pvc_dec.h" diff --git a/decoder/ixheaacd_qmf_dec.c b/decoder/ixheaacd_qmf_dec.c index 8833289..8e8076e 100644 --- a/decoder/ixheaacd_qmf_dec.c +++ b/decoder/ixheaacd_qmf_dec.c @@ -20,7 +20,7 @@ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_basic_ops32.h" @@ -41,7 +41,7 @@ #include "ixheaacd_env_extr.h" #include "ixheaacd_qmf_dec.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_env_calc.h" #include "ixheaacd_interface.h" diff --git a/decoder/ixheaacd_rev_vlc.c b/decoder/ixheaacd_rev_vlc.c index 5c51f64..2092174 100644 --- a/decoder/ixheaacd_rev_vlc.c +++ b/decoder/ixheaacd_rev_vlc.c @@ -20,7 +20,7 @@ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_constants.h" #include "ixheaacd_basic_ops32.h" diff --git a/decoder/ixheaacd_rom.c b/decoder/ixheaacd_rom.c index 9467156..0e10e6a 100644 --- a/decoder/ixheaacd_rom.c +++ b/decoder/ixheaacd_rom.c @@ -17,7 +17,7 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" @@ -224,11 +224,11 @@ const WORD16 ixheaacd_sfb_8_960[] = { const WORD16 ixheaacd_sfb_8_120[] = {4, 8, 12, 16, 20, 24, 28, 36, 44, 52, 60, 72, 88, 108, 120}; -WORD32 ixheaacd_sampling_boundaries[(1 << LEN_SAMP_IDX)] = { +const WORD32 ixheaacd_sampling_boundaries[(1 << LEN_SAMP_IDX)] = { 92017, 75132, 55426, 46009, 37566, 27713, 23004, 18783, 13856, 11502, 9391, 0, 0, 0, 0, 0}; -ia_usac_samp_rate_info ixheaacd_samp_rate_info[(1 << LEN_SAMP_IDX)] = { +const ia_usac_samp_rate_info ixheaacd_samp_rate_info[(1 << LEN_SAMP_IDX)] = { {96000, 41, ixheaacd_sfb_96_1024, 12, ixheaacd_sfb_96_128, 40, ixheaacd_sfb_96_960, 12, ixheaacd_sfb_96_120, 37, ixheaacd_sfb_96_768, 12, @@ -3606,7 +3606,7 @@ const FLOAT64 ixheaacd_power_10_table[28] = { 5.179474679231, 5.623413251903, 6.105402296585, 6.628703161826, 7.196856730012, 7.813707376518, 8.483428982441, 9.210553176895}; -float ixheaacd_dico_lsf_abs_8b_flt[16 * 256] = { +const FLOAT32 ixheaacd_dico_lsf_abs_8b_flt[16 * 256] = { 377.3749f, 688.0079f, 1147.3799f, 1461.0438f, 1786.7794f, 2143.6711f, 2522.1946f, 2889.7402f, 3263.6023f, 3628.4624f, 4005.4351f, 4379.4170f, 4783.9556f, 5157.1753f, 5555.1797f, 5926.6816f, 601.5123f, 1066.8242f, diff --git a/decoder/ixheaacd_sbr_const.h b/decoder/ixheaacd_sbr_const.h index 9137c93..ecf3478 100644 --- a/decoder/ixheaacd_sbr_const.h +++ b/decoder/ixheaacd_sbr_const.h @@ -97,8 +97,9 @@ #define MAX_NUM_QMF_BANDS_ESBR 128 #define SBR_HF_ADJ_OFFSET 2 +#define MPS_SBR_DELAY 6 /* 6 qmf samples */ -#define ESBR_HBE_DELAY_OFFSET 32 +#define ESBR_HBE_DELAY_OFFSET 32 /* 32 qmf samples */ #define HBE_OPER_WIN_LEN (13) #define NO_QMF_SYNTH_CHANNELS 64 diff --git a/decoder/ixheaacd_sbr_crc.c b/decoder/ixheaacd_sbr_crc.c index ee6c9b9..7dede60 100644 --- a/decoder/ixheaacd_sbr_crc.c +++ b/decoder/ixheaacd_sbr_crc.c @@ -17,7 +17,7 @@ ***************************************************************************** * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_sbr_crc.h" diff --git a/decoder/ixheaacd_sbr_dec.c b/decoder/ixheaacd_sbr_dec.c index e58f2d4..a8ac0b6 100644 --- a/decoder/ixheaacd_sbr_dec.c +++ b/decoder/ixheaacd_sbr_dec.c @@ -19,15 +19,15 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" @@ -36,7 +36,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -56,7 +56,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" @@ -450,26 +450,6 @@ VOID ixheaacd_esbr_synthesis_filt_block( ia_sbr_frame_info_data_struct *ptr_frame_data, WORD32 apply_processing, FLOAT32 **qmf_buf_real, FLOAT32 **qmf_buf_imag, WORD32 stereo_config_idx, ia_sbr_tables_struct *sbr_tables_ptr, WORD32 mps_sbr_flag, WORD32 ch_fac) { - WORD32 i, k, p1; - WORD32 *ptr_filt_states; - WORD32 *ptr_filt_states_1; - WORD32 *ptr_filt_states_2; - WORD32 *filter_l; - WORD32 *ploc_qmf_buf_real; - WORD32 *ploc_qmf_buf_imag; - WORD32 out_scalefactor; - WORD32 sixty4; - WORD32 no_synthesis_channels; - WORD32 ixheaacd_drc_offset; - FLOAT32 *syn_buffer; - WORD32 *local_qmf_buffer = ptr_sbr_dec->sbr_scratch_local; - WORD32 *time_out = &(ptr_sbr_dec->sbr_scratch_local[128]); - - ia_sbr_qmf_filter_bank_struct *qmf_bank = - &ptr_sbr_dec->str_synthesis_qmf_bank; - ia_qmf_dec_tables_struct *qmf_dec_tables_ptr = - sbr_tables_ptr->qmf_dec_tables_ptr; - if (!mps_sbr_flag) { ixheaacd_esbr_synthesis_regrp(&qmf_buf_real[0][0], &qmf_buf_imag[0][0], ptr_sbr_dec, ptr_frame_data, ptr_header_data, @@ -479,74 +459,94 @@ VOID ixheaacd_esbr_synthesis_filt_block( ptr_sbr_dec, stereo_config_idx); } - out_scalefactor = 5; - qmf_bank->no_channels = 64; - qmf_bank->esbr_cos_twiddle = - (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l64; - qmf_bank->esbr_alt_sin_twiddle = - (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l64; - - qmf_bank->filter_pos_syn_32 += - qmf_dec_tables_ptr->esbr_qmf_c - qmf_bank->p_filter_32; - qmf_bank->p_filter_32 = qmf_dec_tables_ptr->esbr_qmf_c; - - sixty4 = NO_SYNTHESIS_CHANNELS; + if (stereo_config_idx <= 0) { + WORD32 i, k, p1; + WORD32 *ptr_filt_states; + WORD32 *ptr_filt_states_1; + WORD32 *ptr_filt_states_2; + WORD32 *filter_l; + WORD32 *ploc_qmf_buf_real; + WORD32 *ploc_qmf_buf_imag; + WORD32 out_scalefactor; + WORD32 sixty4; + WORD32 no_synthesis_channels; + WORD32 ixheaacd_drc_offset; + FLOAT32 *syn_buffer; + WORD32 *local_qmf_buffer = ptr_sbr_dec->sbr_scratch_local; + WORD32 *time_out = &(ptr_sbr_dec->sbr_scratch_local[128]); + ia_sbr_qmf_filter_bank_struct *qmf_bank = + &ptr_sbr_dec->str_synthesis_qmf_bank; + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr = + sbr_tables_ptr->qmf_dec_tables_ptr; + out_scalefactor = 5; + qmf_bank->no_channels = 64; + qmf_bank->esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l64; + qmf_bank->esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l64; + + qmf_bank->filter_pos_syn_32 += + qmf_dec_tables_ptr->esbr_qmf_c - qmf_bank->p_filter_32; + qmf_bank->p_filter_32 = qmf_dec_tables_ptr->esbr_qmf_c; + + sixty4 = NO_SYNTHESIS_CHANNELS; + + ptr_filt_states = qmf_bank->filter_states_32; + + no_synthesis_channels = qmf_bank->no_channels; + ptr_filt_states_1 = &ptr_filt_states[0]; + ptr_filt_states_2 = ptr_filt_states_1 + no_synthesis_channels; + + filter_l = qmf_bank->filter_pos_syn_32; + + p1 = 0; + + ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset; - ptr_filt_states = qmf_bank->filter_states_32; + for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (k = 0; k < 64; k++) { + local_qmf_buffer[k + 0] = (WORD32)(qmf_buf_real[i][k] * 64); + local_qmf_buffer[k + 64] = (WORD32)(qmf_buf_imag[i][k] * 64); + } + ploc_qmf_buf_real = local_qmf_buffer; + ploc_qmf_buf_imag = local_qmf_buffer + 64; - no_synthesis_channels = qmf_bank->no_channels; - ptr_filt_states_1 = &ptr_filt_states[0]; - ptr_filt_states_2 = ptr_filt_states_1 + no_synthesis_channels; + ixheaacd_esbr_inv_modulation(ploc_qmf_buf_real, + &ptr_sbr_dec->str_synthesis_qmf_bank, + sbr_tables_ptr->qmf_dec_tables_ptr); - filter_l = qmf_bank->filter_pos_syn_32; + ixheaacd_shiftrountine_with_rnd_hq(ploc_qmf_buf_real, ploc_qmf_buf_imag, + &ptr_filt_states[ixheaacd_drc_offset], + no_synthesis_channels, + out_scalefactor + 1); - p1 = 0; + ixheaacd_esbr_qmfsyn64_winadd(ptr_filt_states_1, ptr_filt_states_2, + filter_l, &time_out[0], ch_fac); - ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset; + syn_buffer = ptr_sbr_dec->time_sample_buf + i * 64; + for (k = 0; k < 64; k++) { + syn_buffer[k] = (FLOAT32)time_out[k] / (1 << 16); + } - for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { - for (k = 0; k < 64; k++) { - local_qmf_buffer[k + 0] = (WORD32)(qmf_buf_real[i][k] * 64); - local_qmf_buffer[k + 64] = (WORD32)(qmf_buf_imag[i][k] * 64); - } - ploc_qmf_buf_real = local_qmf_buffer; - ploc_qmf_buf_imag = local_qmf_buffer + 64; + ptr_filt_states_1 += sixty4; + ptr_filt_states_2 -= sixty4; + sixty4 = -sixty4; + ixheaacd_drc_offset -= 128; - ixheaacd_esbr_inv_modulation(ploc_qmf_buf_real, - &ptr_sbr_dec->str_synthesis_qmf_bank, - sbr_tables_ptr->qmf_dec_tables_ptr); + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280; - ixheaacd_shiftrountine_with_rnd_hq(ploc_qmf_buf_real, ploc_qmf_buf_imag, - &ptr_filt_states[ixheaacd_drc_offset], - no_synthesis_channels, - out_scalefactor + 1); + filter_l += 64; - ixheaacd_esbr_qmfsyn64_winadd(ptr_filt_states_1, ptr_filt_states_2, - filter_l, &time_out[0], ch_fac); + if (filter_l == qmf_bank->p_filter_32 + 640) + filter_l = (WORD32 *)qmf_bank->p_filter_32; - syn_buffer = ptr_sbr_dec->time_sample_buf + i * 64; - for (k = 0; k < 64; k++) { - syn_buffer[k] = (FLOAT32)time_out[k] / (1 << 16); + p1 += no_synthesis_channels; } - ptr_filt_states_1 += sixty4; - ptr_filt_states_2 -= sixty4; - sixty4 = -sixty4; - ixheaacd_drc_offset -= 128; - - if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280; - - filter_l += 64; - - if (filter_l == qmf_bank->p_filter_32 + 640) - filter_l = (WORD32 *)qmf_bank->p_filter_32; - - p1 += no_synthesis_channels; + qmf_bank->filter_pos_syn_32 = filter_l; + qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset; } - qmf_bank->filter_pos_syn_32 = filter_l; - qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset; - if (!mps_sbr_flag) ptr_frame_data->reset_flag = 0; if (apply_processing && !mps_sbr_flag) { @@ -653,11 +653,14 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, WORD32 core_frame_size = ptr_header_data->core_frame_size; if (hbe_flag) { - codec_x_delay = 32; + codec_x_delay = ESBR_HBE_DELAY_OFFSET; } if (upsample_ratio_idx == SBR_UPSAMPLE_IDX_4_1) { codec_x_delay = 2 * codec_x_delay; } + /* fixed decoder delay for bitstreams with SBR 4:1 and stereoConfigIndex 3 + */ + if (mps_sbr_flag) op_delay = MPS_SBR_DELAY; if (hbe_flag || mps_sbr_flag) { core_syn_ch_index = num_anal_bands; @@ -880,6 +883,7 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, if (apply_processing) { WORD16 degree_alias[NO_SYNTHESIS_CHANNELS]; WORD16 *border_vec = ptr_frame_data->str_frame_info_details.border_vec; + IA_ERRORCODE error_code = IA_NO_ERROR; if (low_pow_flag) { memset(degree_alias, 0, NO_SYNTHESIS_CHANNELS * sizeof(WORD16)); @@ -919,13 +923,14 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data, audio_object_type); } - ixheaacd_calc_sbrenvelope( + error_code = ixheaacd_calc_sbrenvelope( &ptr_sbr_dec->str_sbr_scale_fact, &ptr_sbr_dec->str_sbr_calc_env, ptr_header_data, ptr_frame_data, ptr_frame_data_prev, p_arr_qmf_buf_real, p_arr_qmf_buf_imag, degree_alias, low_pow_flag, sbr_tables_ptr, pstr_common_tables, ptr_work_buf_core + (LPC_ORDER << (6 + !low_pow_flag)), audio_object_type); + if (error_code) return error_code; memcpy(ptr_frame_data_prev->sbr_invf_mode, ptr_frame_data->sbr_invf_mode, ptr_header_data->pstr_freq_band_data->num_if_bands * sizeof(WORD32)); diff --git a/decoder/ixheaacd_sbr_rom.c b/decoder/ixheaacd_sbr_rom.c index a827c8f..4bca7de 100644 --- a/decoder/ixheaacd_sbr_rom.c +++ b/decoder/ixheaacd_sbr_rom.c @@ -19,12 +19,12 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_defines.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -39,7 +39,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" diff --git a/decoder/ixheaacd_sbrdec_initfuncs.c b/decoder/ixheaacd_sbrdec_initfuncs.c index 524b80a..a5a2181 100644 --- a/decoder/ixheaacd_sbrdec_initfuncs.c +++ b/decoder/ixheaacd_sbrdec_initfuncs.c @@ -19,23 +19,23 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_sbr_const.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_defines.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -49,7 +49,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_ps_bitdec.h" @@ -1027,14 +1027,13 @@ static PLATFORM_INLINE WORD32 ixheaacd_create_cplx_synt_qmfbank( WORD32 qmf_filter_state_size; memset(ptr_sbr_qmf, 0, sizeof(ia_sbr_qmf_filter_bank_struct)); + qmf_filter_state_size = QMF_FILTER_STATE_SYN_SIZE; if (down_sample_flag) { L = NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED; - qmf_filter_state_size = QMF_FILTER_STATE_SYN_SIZE_DOWN_SAMPLED; ptr_sbr_qmf->usb = NO_SYNTHESIS_CHANNELS_DOWN_SAMPLED; } else { L = NO_SYNTHESIS_CHANNELS; - qmf_filter_state_size = QMF_FILTER_STATE_SYN_SIZE; ptr_sbr_qmf->usb = usb; } diff --git a/decoder/ixheaacd_sbrdec_lpfuncs.c b/decoder/ixheaacd_sbrdec_lpfuncs.c index 33213ec..77e7ed6 100644 --- a/decoder/ixheaacd_sbrdec_lpfuncs.c +++ b/decoder/ixheaacd_sbrdec_lpfuncs.c @@ -20,23 +20,23 @@ #include <string.h> #include <math.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_sbr_const.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_defines.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -50,7 +50,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_ps_bitdec.h" @@ -73,11 +73,12 @@ #define ALIGN_SIZE64(x) ((((x) + 7) >> 3) << 3) -static FLOAT32 ixheaacd_new_bw_table[4][4] = {{0.00f, 0.60f, 0.90f, 0.98f}, - {0.60f, 0.75f, 0.90f, 0.98f}, - {0.00f, 0.75f, 0.90f, 0.98f}, - {0.00f, 0.75f, 0.90f, 0.98f}}; -static WORD32 ixheaacd_inew_bw_table[4][4] = { +static const FLOAT32 ixheaacd_new_bw_table[4][4] = { + {0.00f, 0.60f, 0.90f, 0.98f}, + {0.60f, 0.75f, 0.90f, 0.98f}, + {0.00f, 0.75f, 0.90f, 0.98f}, + {0.00f, 0.75f, 0.90f, 0.98f}}; +static const WORD32 ixheaacd_inew_bw_table[4][4] = { {0x00000000, 0x4ccccccd, 0x73333333, 0x7d70a3d7}, {0x4ccccccd, 0x60000000, 0x73333333, 0x7d70a3d7}, {0x00000000, 0x60000000, 0x73333333, 0x7d70a3d7}, @@ -110,8 +111,8 @@ WORD32 ixheaacd_derive_lim_band_tbl( WORD16 sub_band_start = f_low_tbl[0]; WORD16 sub_band_end = f_low_tbl[num_low_bnd]; - WORD16 limbnd_per_oct[4] = {(WORD16)0x2000, (WORD16)0x2666, (WORD16)0x4000, - (WORD16)0x6000}; + static const WORD16 limbnd_per_oct[4] = {(WORD16)0x2000, (WORD16)0x2666, + (WORD16)0x4000, (WORD16)0x6000}; if (limiter_bands == 0) { f_lim_tbl[0] = 0; @@ -355,13 +356,16 @@ WORD32 ixheaacd_reset_hf_generator(ia_sbr_hf_generator_struct *ptr_hf_gen_str, while (((sb - usb) < 0) && (patch < MAX_NUM_PATCHES)) { ia_patch_param_struct *ptr_loc_patch_param = &p_str_patch_param[patch]; - + WORD16 abs_sb, flag_break = 0; ptr_loc_patch_param->guard_start_band = sb; sb = (sb + GUARDBANDS); ptr_loc_patch_param->dst_start_band = sb; num_bands_in_patch = (goal_sb - sb); - + if ((num_bands_in_patch <= 0) && + ((num_bands_in_patch - (lsb - src_start_band)) < 0)) { + flag_break = 1; + } if ((num_bands_in_patch - (lsb - src_start_band)) >= 0) { patch_stride = sb - src_start_band; patch_stride = (WORD16)(patch_stride & ~1); @@ -386,9 +390,12 @@ WORD32 ixheaacd_reset_hf_generator(ia_sbr_hf_generator_struct *ptr_hf_gen_str, } src_start_band = SHIFT_START_SB; + abs_sb = ixheaacd_abs16_sat((WORD16)((sb - goal_sb))) - 3; - if ((ixheaacd_abs16_sat((WORD16)((sb - goal_sb))) - 3) < 0) { + if (abs_sb < 0) { goal_sb = usb; + } else { + if (flag_break == 1) break; } } @@ -413,6 +420,8 @@ WORD32 ixheaacd_reset_hf_generator(ia_sbr_hf_generator_struct *ptr_hf_gen_str, temp = ixheaacd_max32(temp, p_str_patch_param[patch].src_end_band); } + if (sb > temp) return IA_FATAL_ERROR; + pstr_transposer_settings->start_patch = sb; pstr_transposer_settings->stop_patch = temp; diff --git a/decoder/ixheaacd_sbrdecoder.c b/decoder/ixheaacd_sbrdecoder.c index 4ab91f7..53275f6 100644 --- a/decoder/ixheaacd_sbrdecoder.c +++ b/decoder/ixheaacd_sbrdecoder.c @@ -19,23 +19,23 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_sbr_const.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_defines.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -49,7 +49,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_ps_bitdec.h" @@ -500,6 +500,7 @@ IA_ERRORCODE ixheaacd_applysbr( if (err || (ptr_header_data[k]->sync_state == SBR_NOT_INITIALIZED)) { WORD32 lr1 = ps_enable ? 2 : num_channels; ixheaacd_prepare_upsamp(ptr_header_data, pstr_sbr_channel, lr1); + if (err) return err; } if (frame_status && (ptr_header_data[k]->sync_state == SBR_ACTIVE)) { diff --git a/decoder/ixheaacd_spectrum_dec.c b/decoder/ixheaacd_spectrum_dec.c index c827a02..8d73ee6 100644 --- a/decoder/ixheaacd_spectrum_dec.c +++ b/decoder/ixheaacd_spectrum_dec.c @@ -20,7 +20,7 @@ #include <math.h> #include <stdio.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" @@ -45,11 +45,6 @@ #include "ixheaacd_bit_extract.h" #include "ixheaacd_func_def.h" - -#include <math.h> -#include <stdio.h> -#include <string.h> - #include "ixheaacd_interface.h" #include "ixheaacd_info.h" @@ -91,8 +86,9 @@ VOID ixheaacd_read_tns_u(ia_sfb_info_struct *ptr_sfb_info, WORD16 *sp, tmp, s_mask, n_mask; ia_tns_filter_struct *tns_filt; ia_tns_info_struct *pstr_tns_info; - static WORD16 sgn_mask[] = {0x2, 0x4, 0x8}; - static WORD16 neg_mask[] = {(WORD16)0xfffc, (WORD16)0xfff8, (WORD16)0xfff0}; + static const WORD16 sgn_mask[] = {0x2, 0x4, 0x8}; + static const WORD16 neg_mask[] = {(WORD16)0xfffc, (WORD16)0xfff8, + (WORD16)0xfff0}; WORD16 n_filt_bits; WORD16 start_band_bits; @@ -457,4 +453,4 @@ WORD32 ixheaacd_fd_channel_stream( } return 0; -} +}
\ No newline at end of file diff --git a/decoder/ixheaacd_stereo.c b/decoder/ixheaacd_stereo.c index ac0f313..28a3e31 100644 --- a/decoder/ixheaacd_stereo.c +++ b/decoder/ixheaacd_stereo.c @@ -18,21 +18,21 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_pulsedata.h" diff --git a/decoder/ixheaacd_struct_def.h b/decoder/ixheaacd_struct_def.h index ee52f0c..57d2e00 100644 --- a/decoder/ixheaacd_struct_def.h +++ b/decoder/ixheaacd_struct_def.h @@ -32,6 +32,7 @@ #define MAX_NUM_OTT_AT \ (MAX_OUTPUT_CHANNELS * ((1 << MAX_ARBITRARY_TREE_LEVELS) - 1)) #define MAX_PARAMETER_BANDS (28) +#define MAX_DECOR_CONFIG_IDX (2) #define MAX_HYBRID_BANDS (MAX_NUM_QMF_BANDS - 3 + 10) @@ -234,6 +235,8 @@ typedef struct ia_aac_dec_state_struct { ia_sbr_header_data_struct str_sbr_config; jmp_buf xaac_jmp_buf; WORD32 decode_create_done; + WORD32 fatal_err_present; + WORD8 *pers_mem_ptr; } ia_aac_dec_state_struct; typedef struct ia_exhaacplus_dec_api_struct { diff --git a/decoder/ixheaacd_tcx_fwd_alcnx.c b/decoder/ixheaacd_tcx_fwd_alcnx.c index bf579d2..617f20e 100644 --- a/decoder/ixheaacd_tcx_fwd_alcnx.c +++ b/decoder/ixheaacd_tcx_fwd_alcnx.c @@ -22,7 +22,7 @@ #include <stdio.h> #include <math.h> #include <string.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" @@ -50,9 +50,8 @@ #include "ixheaacd_acelp_com.h" #include "ixheaacd_constants.h" -#include <ixheaacd_type_def.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" static FLOAT32 ixheaacd_randomsign(UWORD32 *seed); #define ABS(A) ((A) < 0 ? (-A) : (A)) diff --git a/decoder/ixheaacd_tcx_fwd_mdct.c b/decoder/ixheaacd_tcx_fwd_mdct.c index 8778224..af46596 100644 --- a/decoder/ixheaacd_tcx_fwd_mdct.c +++ b/decoder/ixheaacd_tcx_fwd_mdct.c @@ -24,11 +24,10 @@ #include <string.h> #include "ixheaacd_cnst.h" -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_acelp_com.h" -#include <ixheaacd_type_def.h> #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" @@ -49,8 +48,8 @@ #include "ixheaacd_sbr_const.h" #include "ixheaacd_constants.h" -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_main.h" #include "ixheaacd_arith_dec.h" diff --git a/decoder/ixheaacd_thumb_ps_dec.c b/decoder/ixheaacd_thumb_ps_dec.c index 9810148..39b7b72 100644 --- a/decoder/ixheaacd_thumb_ps_dec.c +++ b/decoder/ixheaacd_thumb_ps_dec.c @@ -19,17 +19,17 @@ */ #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops_arr.h" #include "ixheaacd_basic_ops.h" #include "ixheaacd_defines.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_basic_funcs.h" @@ -37,7 +37,7 @@ #include "ixheaacd_sbrdecsettings.h" #include "ixheaacd_defines.h" #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_pulsedata.h" #include "ixheaacd_drc_data_struct.h" @@ -48,12 +48,12 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_env_extr.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_ps_dec.h" #include "ixheaacd_qmf_dec.h" diff --git a/decoder/ixheaacd_tns.c b/decoder/ixheaacd_tns.c index 9a6cdf1..a16736c 100644 --- a/decoder/ixheaacd_tns.c +++ b/decoder/ixheaacd_tns.c @@ -20,7 +20,7 @@ #include <math.h> #include <stdio.h> -#include <ixheaacd_type_def.h> +#include "ixheaacd_type_def.h" #include "ixheaacd_bitbuffer.h" #include "ixheaacd_interface.h" @@ -42,9 +42,9 @@ #include "ixheaacd_main.h" #include "ixheaacd_arith_dec.h" #include "ixheaacd_function_selector.h" -#include <ixheaacd_constants.h> -#include <ixheaacd_basic_ops32.h> -#include <ixheaacd_basic_ops40.h> +#include "ixheaacd_constants.h" +#include "ixheaacd_basic_ops32.h" +#include "ixheaacd_basic_ops40.h" #define sfb_offset(x) (((x) > 0) ? sfb_top[(x)-1] : 0) diff --git a/decoder/ixheaacd_vec_baisc_ops.h b/decoder/ixheaacd_vec_baisc_ops.h index a71ccfd..c57e17d 100644 --- a/decoder/ixheaacd_vec_baisc_ops.h +++ b/decoder/ixheaacd_vec_baisc_ops.h @@ -58,4 +58,7 @@ WORD8 ixheaacd_windowing_short4(WORD32 *src1, WORD32 *win_fwd, WORD32 *fp, VOID ixheaacd_scale_down(WORD32 *dest, WORD32 *src, WORD32 len, WORD8 shift1, WORD8 shift2); +VOID ixheaacd_scale_down_adj(WORD32 *dest, WORD32 *src, WORD32 len, + WORD8 shift1, WORD8 shift2); + #endif diff --git a/decoder/x86/ixheaacd_function_selector_x86.c b/decoder/x86/ixheaacd_function_selector_x86.c index e70ab9a..f9c71fa 100644 --- a/decoder/x86/ixheaacd_function_selector_x86.c +++ b/decoder/x86/ixheaacd_function_selector_x86.c @@ -20,15 +20,15 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_sbrdecsettings.h" @@ -37,7 +37,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_pulsedata.h" @@ -53,7 +53,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_block.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -198,11 +198,11 @@ VOID(*ixheaacd_mps_complex_fft_64) WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec; VOID(*ixheaacd_mps_synt_pre_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec; VOID(*ixheaacd_mps_synt_post_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec; VOID(*ixheaacd_calc_pre_twid) @@ -214,8 +214,9 @@ VOID(*ixheaacd_calc_post_twid) const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec; VOID(*ixheaacd_mps_synt_post_fft_twiddle) -(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; +(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; VOID(*ixheaacd_mps_synt_out_calc) (WORD32 resolution, WORD32 *out, WORD32 *state, diff --git a/decoder/x86_64/ixheaacd_function_selector_x86_64.c b/decoder/x86_64/ixheaacd_function_selector_x86_64.c index e70ab9a..f9c71fa 100644 --- a/decoder/x86_64/ixheaacd_function_selector_x86_64.c +++ b/decoder/x86_64/ixheaacd_function_selector_x86_64.c @@ -20,15 +20,15 @@ #include <stdio.h> #include <string.h> #include "ixheaacd_sbr_common.h" -#include <ixheaacd_type_def.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_ops32.h" +#include "ixheaacd_basic_ops16.h" +#include "ixheaacd_basic_ops40.h" #include "ixheaacd_basic_ops.h" -#include <ixheaacd_basic_op.h> +#include "ixheaacd_basic_op.h" #include "ixheaacd_intrinsics.h" #include "ixheaacd_common_rom.h" #include "ixheaacd_sbrdecsettings.h" @@ -37,7 +37,7 @@ #include "ixheaacd_pns.h" -#include <ixheaacd_aac_rom.h> +#include "ixheaacd_aac_rom.h" #include "ixheaacd_aac_imdct.h" #include "ixheaacd_pulsedata.h" @@ -53,7 +53,7 @@ #include "ixheaacd_sbr_scale.h" #include "ixheaacd_lpp_tran.h" #include "ixheaacd_env_extr_part.h" -#include <ixheaacd_sbr_rom.h> +#include "ixheaacd_sbr_rom.h" #include "ixheaacd_block.h" #include "ixheaacd_hybrid.h" #include "ixheaacd_ps_dec.h" @@ -198,11 +198,11 @@ VOID(*ixheaacd_mps_complex_fft_64) WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec; VOID(*ixheaacd_mps_synt_pre_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec; VOID(*ixheaacd_mps_synt_post_twiddle) -(WORD32 *ptr_in, WORD32 *table_re, WORD32 *table_im, +(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im, WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec; VOID(*ixheaacd_calc_pre_twid) @@ -214,8 +214,9 @@ VOID(*ixheaacd_calc_post_twid) const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec; VOID(*ixheaacd_mps_synt_post_fft_twiddle) -(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, WORD32 *table_re, - WORD32 *table_im, WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; +(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re, + const WORD32 *table_im, + WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec; VOID(*ixheaacd_mps_synt_out_calc) (WORD32 resolution, WORD32 *out, WORD32 *state, |